Spaces:
Build error
Build error
Build app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,25 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
|
|
|
|
|
|
|
4 |
|
5 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
with gr.Blocks(
|
8 |
-
title="
|
9 |
theme=themes.Soft(primary_hue="blue", secondary_hue="blue"), # Apply blue theme
|
10 |
) as demo:
|
11 |
# Header with Image
|
@@ -22,7 +36,7 @@ with gr.Blocks(
|
|
22 |
<a href="https://huggingface.co/archerfmy0831/sd-t2i-360panoimage" target="_blank">[Models]</a>
|
23 |
</div>
|
24 |
</div>
|
25 |
-
""")
|
26 |
|
27 |
# Credits and Information
|
28 |
gr.Markdown(
|
@@ -37,10 +51,11 @@ with gr.Blocks(
|
|
37 |
t2p_input = gr.Textbox(label="Enter your prompt", lines=3)
|
38 |
t2p_upscale = gr.Checkbox(label="Upscale (takes about 60 seconds 6144x3072 resolution)")
|
39 |
t2p_generate = gr.Button("Generate Panorama")
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
# A-Frame Preview (HTML)
|
44 |
with gr.Row():
|
45 |
t2p_image_output = gr.Image(label="Generated 360 Image")
|
46 |
t2p_iframe = gr.HTML(label="A-Frame Preview")
|
@@ -50,7 +65,7 @@ with gr.Blocks(
|
|
50 |
|
51 |
# Modified Generate Function
|
52 |
def generate_with_update(prompt, upscale, trigger):
|
53 |
-
output, image = text_to_pano(prompt, upscale)
|
54 |
|
55 |
# A-Frame Preview Generation
|
56 |
iframe_html = f"""
|
@@ -67,12 +82,12 @@ with gr.Blocks(
|
|
67 |
</html>
|
68 |
"""
|
69 |
|
70 |
-
return
|
71 |
|
72 |
t2p_generate.click(
|
73 |
generate_with_update,
|
74 |
inputs=[t2p_input, t2p_upscale, update_trigger],
|
75 |
-
outputs=[
|
76 |
)
|
77 |
|
78 |
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")
|
11 |
+
|
12 |
+
# Initialize pipelines
|
13 |
+
txt2panoimg = Text2360PanoramaImagePipeline(model_path, torch_dtype=torch.float16)
|
14 |
+
|
15 |
+
@spaces.GPU(duration=200)
|
16 |
+
def text_to_pano(prompt, upscale):
|
17 |
+
input_data = {'prompt': prompt, 'upscale': upscale, 'refinement': False}
|
18 |
+
output = txt2panoimg(input_data)
|
19 |
+
return output, output
|
20 |
|
21 |
with gr.Blocks(
|
22 |
+
title="AI FOR VR 101, MHESI FAIR 2024 RESEARCH",
|
23 |
theme=themes.Soft(primary_hue="blue", secondary_hue="blue"), # Apply blue theme
|
24 |
) as demo:
|
25 |
# Header with Image
|
|
|
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(
|
|
|
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 |
+
# No Pannellum here
|
55 |
+
with gr.Column(variant="default"): # This could be removed or used for something else
|
56 |
+
pass
|
57 |
|
58 |
+
# A-Frame Preview (HTML) and Generated Image
|
59 |
with gr.Row():
|
60 |
t2p_image_output = gr.Image(label="Generated 360 Image")
|
61 |
t2p_iframe = gr.HTML(label="A-Frame Preview")
|
|
|
65 |
|
66 |
# Modified Generate Function
|
67 |
def generate_with_update(prompt, upscale, trigger):
|
68 |
+
output, image = text_to_pano(prompt, upscale) # Assuming text_to_pano returns image path
|
69 |
|
70 |
# A-Frame Preview Generation
|
71 |
iframe_html = f"""
|
|
|
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=[t2p_image_output, t2p_iframe, update_trigger] # Update outputs
|
91 |
)
|
92 |
|
93 |
demo.launch()
|