import gradio as gr
import diff
import os
from PIL import Image
sky = "https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/sky.png"
platform = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/platform.png'
star = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/star.png'
bomb = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/bomb.png'
dude = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/dude.png'
def game_fn(sky=sky,platform=platform,star=star,bomb=bomb,dude=dude):
html_mod=f"""
"""
return html_mod
def update_game(sky=None,platform=None,star=None,bomb=None,dude=None)
return game_fn(sky=sky)
def dif_fn(inp):
output=diff.send_it(inp,5,1)
outp=Image.open(output[0])
outp.save("tmp_sky.png")
out = os.path.abspath("tmp_sky.png")
out_url = f'https://omnibus-game-test.hf.space/file={out}'
return output[0],out_url
with gr.Blocks() as app:
with gr.Row():
with gr.Column():
prompt=gr.Textbox()
with gr.Row():
btn=gr.Button("Make Image")
game_btn=gr.Button("Use Image")
out_im=gr.Image(type='filepath')
out_url=gr.Textbox(visible=False)
html_game = gr.HTML()
update_game.click(game_fn,[out_url],html_game)
btn.click(dif_fn,prompt,out_im)
app.load(game_fn,None,html_game)
app.launch()