Update app.py
Browse files
app.py
CHANGED
@@ -33,14 +33,14 @@ def update_game(inp):
|
|
33 |
|
34 |
return game_fn(sky=sky)
|
35 |
|
36 |
-
def
|
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=
|
44 |
#output=dif(inp)
|
45 |
print(output)
|
46 |
outp=Image.open(output[0])
|
@@ -51,22 +51,21 @@ def star_fn(inp):
|
|
51 |
elif width < height:
|
52 |
outp = outp.resize((800,800*rat))
|
53 |
else:
|
54 |
-
outp = outp.resize((
|
55 |
-
outp.save(f"{uid}
|
56 |
-
out = os.path.abspath(f"{uid}
|
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+=" "
|
66 |
#dif = gr.Interface.load("models/stabilityai/stable-diffusion-2-1-base", live=True),
|
67 |
#dif = models[0]
|
68 |
uid=uuid.uuid4()
|
69 |
-
output=
|
70 |
#output=dif(inp)
|
71 |
print(output)
|
72 |
outp=Image.open(output[0])
|
@@ -77,9 +76,9 @@ def sky_fn(inp):
|
|
77 |
elif width < height:
|
78 |
outp = outp.resize((800,800*rat))
|
79 |
else:
|
80 |
-
outp = outp.resize((
|
81 |
-
outp.save(f"{uid}
|
82 |
-
out = os.path.abspath(f"{uid}
|
83 |
#out = os.path.abspath(outp)
|
84 |
out_url = f'https://omnibus-game-test.hf.space/file={out}'
|
85 |
return output[0],out_url
|
@@ -93,11 +92,13 @@ with gr.Blocks() as app:
|
|
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 |
-
|
|
|
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,
|
101 |
-
btn.click(sky_fn,prompt,[out_im_sky,out_sky_url])
|
102 |
-
|
|
|
103 |
app.launch()
|
|
|
33 |
|
34 |
return game_fn(sky=sky)
|
35 |
|
36 |
+
def sky_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=proc1.send_it(inp,5,1)
|
44 |
#output=dif(inp)
|
45 |
print(output)
|
46 |
outp=Image.open(output[0])
|
|
|
51 |
elif width < height:
|
52 |
outp = outp.resize((800,800*rat))
|
53 |
else:
|
54 |
+
outp = outp.resize((800,536))
|
55 |
+
outp.save(f"{uid}_sky.png")
|
56 |
+
out = os.path.abspath(f"{uid}_sky.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 |
+
def star_fn(inp):
|
|
|
62 |
rand = random.randint(1,200)
|
63 |
for i in range(rand):
|
64 |
inp+=" "
|
65 |
#dif = gr.Interface.load("models/stabilityai/stable-diffusion-2-1-base", live=True),
|
66 |
#dif = models[0]
|
67 |
uid=uuid.uuid4()
|
68 |
+
output=proc2.send_it(inp,5,1)
|
69 |
#output=dif(inp)
|
70 |
print(output)
|
71 |
outp=Image.open(output[0])
|
|
|
76 |
elif width < height:
|
77 |
outp = outp.resize((800,800*rat))
|
78 |
else:
|
79 |
+
outp = outp.resize((24,24))
|
80 |
+
outp.save(f"{uid}_star.png")
|
81 |
+
out = os.path.abspath(f"{uid}_star.png")
|
82 |
#out = os.path.abspath(outp)
|
83 |
out_url = f'https://omnibus-game-test.hf.space/file={out}'
|
84 |
return output[0],out_url
|
|
|
92 |
update_game=gr.Button("Use Image")
|
93 |
out_im_sky=gr.Image(type='filepath',height=50)
|
94 |
out_im_star=gr.Image(type='filepath',height=50)
|
95 |
+
out_sky_url=gr.Textbox(visible=False)
|
96 |
+
out_star_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,out_star_url],html_game)
|
101 |
+
btn.click(sky_fn,prompt,[out_im_sky,out_sky_url])
|
102 |
+
btn.click(star_fn,prompt,[out_im_star,out_star_url])
|
103 |
+
app.load(sky_fn,start_prompt,[out_im_sky,out_sky_url]).then(game_fn,[out_sky_url],html_game)
|
104 |
app.launch()
|