Omnibus commited on
Commit
e1e351c
1 Parent(s): 609d418

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -6
app.py CHANGED
@@ -16,7 +16,7 @@ dude = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/dude
16
 
17
 
18
 
19
- def game_fn(sky=sky,platform=platform,star=star,bomb=bomb,dude=dude):
20
  html_mod=f"""
21
  <div id="demo" style="height:600px">
22
  <iframe
@@ -33,7 +33,33 @@ def update_game(inp):
33
 
34
  return game_fn(sky=sky)
35
 
36
- def dif_fn(inp):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  rand = random.randint(1,200)
38
  for i in range(rand):
39
  inp+=" "
@@ -65,12 +91,13 @@ with gr.Blocks() as app:
65
  with gr.Row():
66
  btn=gr.Button("Make Image")
67
  update_game=gr.Button("Use Image")
68
- out_im=gr.Image(type='filepath')
 
69
  out_url=gr.Textbox(visible=False)
70
  start_prompt=gr.Textbox(value="beautiful landscape, real, 8k",visible=False)
71
  html_game = gr.HTML()
72
 
73
- update_game.click(game_fn,[out_url],html_game)
74
- btn.click(dif_fn,prompt,[out_im,out_url])
75
- app.load(dif_fn,start_prompt,[out_im,out_url]).then(game_fn,[out_url],html_game)
76
  app.launch()
 
16
 
17
 
18
 
19
+ def game_fn(sky=sky,star=star,bomb=bomb,platform=platform,dude=dude):
20
  html_mod=f"""
21
  <div id="demo" style="height:600px">
22
  <iframe
 
33
 
34
  return game_fn(sky=sky)
35
 
36
+ def star_fn(inp):
37
+ rand = random.randint(1,200)
38
+ for i in range(rand):
39
+ inp+=" "
40
+ #dif = gr.Interface.load("models/stabilityai/stable-diffusion-2-1-base", live=True),
41
+ #dif = models[0]
42
+ uid=uuid.uuid4()
43
+ output=diff.send_it(inp,5,1)
44
+ #output=dif(inp)
45
+ print(output)
46
+ outp=Image.open(output[0])
47
+ width, height = outp.size
48
+ rat = width/height
49
+ if width > height:
50
+ outp = outp.resize((600*rat,600))
51
+ elif width < height:
52
+ outp = outp.resize((800,800*rat))
53
+ else:
54
+ outp = outp.resize((24,24))
55
+ outp.save(f"{uid}_star.png")
56
+ out = os.path.abspath(f"{uid}_star.png")
57
+ #out = os.path.abspath(outp)
58
+ out_url = f'https://omnibus-game-test.hf.space/file={out}'
59
+ return output[0],out_url
60
+
61
+
62
+ def sky_fn(inp):
63
  rand = random.randint(1,200)
64
  for i in range(rand):
65
  inp+=" "
 
91
  with gr.Row():
92
  btn=gr.Button("Make Image")
93
  update_game=gr.Button("Use Image")
94
+ out_im_sky=gr.Image(type='filepath',height=50)
95
+ out_im_star=gr.Image(type='filepath',height=50)
96
  out_url=gr.Textbox(visible=False)
97
  start_prompt=gr.Textbox(value="beautiful landscape, real, 8k",visible=False)
98
  html_game = gr.HTML()
99
 
100
+ update_game.click(game_fn,[out_sky_url,star_url],html_game)
101
+ btn.click(sky_fn,prompt,[out_im_sky,out_sky_url]).then(star_fn,prompt,[out_im_star,out_star_url])
102
+ app.load(sky_fn,start_prompt,[out_im,out_url]).then(game_fn,[out_sky_url,out_star_url],html_game)
103
  app.launch()