File size: 1,801 Bytes
6634db1
83300eb
42ec9a0
 
6634db1
500a5b0
4cb7e61
8f4468f
 
 
c84a6e6
c4f9926
1bef23c
 
 
 
 
 
 
 
 
 
 
6614cbc
c2de16e
42ec9a0
 
 
83300eb
4714325
42ec9a0
 
 
 
 
83300eb
6614cbc
83300eb
 
 
1bef23c
 
c2de16e
0c30387
42ec9a0
2e84177
42ec9a0
 
e955094
1bef23c
6634db1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"""
        <div id="demo" style="height:600px">
            <iframe
            id="myIframe"
            src="https://omnibus-game-test-static.static.hf.space/index.html?sky={sky}&platform={platform}&star={star}&bomb={bomb}&dude={dude}"        
        	frameborder="0"
        	width="100%"
            height="100%"
            ></iframe>
        </div>"""
    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")
                update_game=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,out_url])
    app.load(game_fn,None,html_game)
app.launch()