Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import diff
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
sky = "https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/sky.png"
|
| 7 |
platform = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/platform.png'
|
|
@@ -22,9 +22,17 @@ def game_fn(sky=sky,platform=platform,star=star,bomb=bomb,dude=dude):
|
|
| 22 |
</div>"""
|
| 23 |
return html_mod
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def dif_fn(inp):
|
| 26 |
output=diff.send_it(inp,5,1)
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
with gr.Blocks() as app:
|
| 30 |
with gr.Row():
|
|
@@ -34,8 +42,10 @@ with gr.Blocks() as app:
|
|
| 34 |
btn=gr.Button("Make Image")
|
| 35 |
game_btn=gr.Button("Use Image")
|
| 36 |
out_im=gr.Image(type='filepath')
|
|
|
|
| 37 |
html_game = gr.HTML()
|
| 38 |
-
|
|
|
|
| 39 |
btn.click(dif_fn,prompt,out_im)
|
| 40 |
app.load(game_fn,None,html_game)
|
| 41 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import diff
|
| 3 |
+
import os
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
sky = "https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/sky.png"
|
| 7 |
platform = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/platform.png'
|
|
|
|
| 22 |
</div>"""
|
| 23 |
return html_mod
|
| 24 |
|
| 25 |
+
def update_game(sky=None,platform=None,star=None,bomb=None,dude=None)
|
| 26 |
+
|
| 27 |
+
return game_fn(sky=sky)
|
| 28 |
+
|
| 29 |
def dif_fn(inp):
|
| 30 |
output=diff.send_it(inp,5,1)
|
| 31 |
+
outp=Image.open(output[0])
|
| 32 |
+
outp.save("tmp_sky.png")
|
| 33 |
+
out = os.path.abspath("tmp_sky.png")
|
| 34 |
+
out_url = f'https://omnibus-game-test.hf.space/file={out}'
|
| 35 |
+
return output[0],out_url
|
| 36 |
|
| 37 |
with gr.Blocks() as app:
|
| 38 |
with gr.Row():
|
|
|
|
| 42 |
btn=gr.Button("Make Image")
|
| 43 |
game_btn=gr.Button("Use Image")
|
| 44 |
out_im=gr.Image(type='filepath')
|
| 45 |
+
out_url=gr.Textbox(visible=False)
|
| 46 |
html_game = gr.HTML()
|
| 47 |
+
|
| 48 |
+
update_game.click(game_fn,[out_url],html_game)
|
| 49 |
btn.click(dif_fn,prompt,out_im)
|
| 50 |
app.load(game_fn,None,html_game)
|
| 51 |
app.launch()
|