Spaces:
Build error
Build error
Build
Browse files
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
|
|
3 |
import torch
|
4 |
from huggingface_hub import snapshot_download
|
5 |
from txt2panoimg import Text2360PanoramaImagePipeline
|
6 |
from PIL import Image
|
7 |
-
from gradio import themes
|
8 |
|
9 |
# Download the model
|
10 |
model_path = snapshot_download("archerfmy0831/sd-t2i-360panoimage")
|
@@ -18,76 +18,38 @@ def text_to_pano(prompt, upscale):
|
|
18 |
output = txt2panoimg(input_data)
|
19 |
return output, output
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
<div style="display: flex; align-items: center; justify-content: space-between;">
|
29 |
-
<img src="https://ant.dpu.ac.th/wp-content/uploads/2024/04/dpulogo.png" width="150" height="50">
|
30 |
-
<div>
|
31 |
-
<h1 align="center">SD-T2I-360PanoImage</h1>
|
32 |
-
<p align="center">AI FOR VR 360° Panorama Image Generator</p>
|
33 |
-
</div>
|
34 |
-
<div style="font-size:12px; text-align: right;">
|
35 |
-
<a href="https://github.com/ArcherFMY/SD-T2I-360PanoImage/" target="_blank">[Github]</a>
|
36 |
-
<a href="https://huggingface.co/archerfmy0831/sd-t2i-360panoimage" target="_blank">[Models]</a>
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
""")
|
40 |
-
|
41 |
-
# Credits and Information
|
42 |
-
gr.Markdown(
|
43 |
-
"""
|
44 |
-
This study was conducted in the College of Creative Design and Entertainment Technology laboratory at Dhurakij Pundit University by Asst. Prof. Banyapon Poolsawas. The project builds upon the SD-T2I-360PanoImage repository (https://github.com/ArcherFMY/SD-T2I-360PanoImage/) for Text-to-360Panorama Sample and Build it with aframe VR.
|
45 |
-
"""
|
46 |
-
)
|
47 |
|
48 |
-
|
|
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
t2p_input = gr.Textbox(label="Enter your prompt", lines=3)
|
52 |
t2p_upscale = gr.Checkbox(label="Upscale (takes about 60 seconds 6144x3072 resolution)")
|
53 |
t2p_generate = gr.Button("Generate Panorama")
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
# A-Frame Preview (HTML) and Generated Image
|
59 |
with gr.Row():
|
60 |
-
t2p_image_output = gr.Image(label="Generated
|
61 |
-
t2p_iframe = gr.HTML(label="A-Frame Preview")
|
62 |
|
63 |
-
#
|
64 |
update_trigger = gr.State(value=0)
|
65 |
|
66 |
-
# Modified Generate Function
|
67 |
def generate_with_update(prompt, upscale, trigger):
|
68 |
-
output, image = text_to_pano(prompt, upscale)
|
69 |
-
|
70 |
-
# A-Frame Preview Generation
|
71 |
-
iframe_html = f"""
|
72 |
-
<html>
|
73 |
-
<head>
|
74 |
-
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
|
75 |
-
</head>
|
76 |
-
<body>
|
77 |
-
<a-scene>
|
78 |
-
<a-sky src="{image}" rotation="0 -130 0"></a-sky>
|
79 |
-
<a-text font="kelsonsans" value="Create from AI" width="6" position="-2.5 0.25 -1.5" rotation="0 15 0"></a-text>
|
80 |
-
</a-scene>
|
81 |
-
</body>
|
82 |
-
</html>
|
83 |
-
"""
|
84 |
-
|
85 |
-
return image, iframe_html, trigger + 1 # Return the image path instead of Pannellum output
|
86 |
|
87 |
t2p_generate.click(
|
88 |
generate_with_update,
|
89 |
inputs=[t2p_input, t2p_upscale, update_trigger],
|
90 |
-
outputs=[
|
91 |
)
|
92 |
|
93 |
-
demo.launch()
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
+
from gradio_pannellum import Pannellum
|
4 |
import torch
|
5 |
from huggingface_hub import snapshot_download
|
6 |
from txt2panoimg import Text2360PanoramaImagePipeline
|
7 |
from PIL import Image
|
|
|
8 |
|
9 |
# Download the model
|
10 |
model_path = snapshot_download("archerfmy0831/sd-t2i-360panoimage")
|
|
|
18 |
output = txt2panoimg(input_data)
|
19 |
return output, output
|
20 |
|
21 |
+
title = """<h1 align="center">SD-T2I-360PanoImage</h1>
|
22 |
+
<p align="center">360° Panorama Image Generation</p>
|
23 |
+
<p><center>
|
24 |
+
<a href="https://github.com/ArcherFMY/SD-T2I-360PanoImage/" target="_blank">[Github]</a>
|
25 |
+
<a href="https://huggingface.co/archerfmy0831/sd-t2i-360panoimage" target="_blank">[Models]</a>
|
26 |
+
</center></p>
|
27 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
with gr.Blocks(theme='bethecloud/storj_theme') as demo:
|
30 |
+
gr.HTML(title)
|
31 |
with gr.Row():
|
32 |
with gr.Column():
|
33 |
t2p_input = gr.Textbox(label="Enter your prompt", lines=3)
|
34 |
t2p_upscale = gr.Checkbox(label="Upscale (takes about 60 seconds 6144x3072 resolution)")
|
35 |
t2p_generate = gr.Button("Generate Panorama")
|
36 |
+
with gr.Column(variant="default"):
|
37 |
+
t2p_output = Pannellum(show_label=False, interactive=True)
|
38 |
+
|
|
|
|
|
39 |
with gr.Row():
|
40 |
+
t2p_image_output = gr.Image(label="Generated Image")
|
|
|
41 |
|
42 |
+
# Add a hidden component to store a random value
|
43 |
update_trigger = gr.State(value=0)
|
44 |
|
|
|
45 |
def generate_with_update(prompt, upscale, trigger):
|
46 |
+
output, image = text_to_pano(prompt, upscale)
|
47 |
+
return output, image, trigger + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
t2p_generate.click(
|
50 |
generate_with_update,
|
51 |
inputs=[t2p_input, t2p_upscale, update_trigger],
|
52 |
+
outputs=[t2p_output, t2p_image_output, update_trigger]
|
53 |
)
|
54 |
|
55 |
+
demo.launch()
|