Spaces:
Runtime error
Runtime error
Update
Browse files- app.py +121 -20
- assets/.ipynb_checkpoints/video_search_app_title-checkpoint.png +3 -0
- assets/gaudi.png +3 -0
- assets/intel-labs.png +3 -0
- assets/intelone-bodytext-font-family-regular.ttf +0 -0
- assets/video_search_app_title.png +3 -0
- assets/video_search_app_ui.png +3 -0
- assets/xeon.png +3 -0
- requirements.txt +3 -3
app.py
CHANGED
@@ -1,26 +1,127 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
3 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
inputs=[url_input, prompt_input],
|
22 |
-
outputs=[outputs],
|
23 |
-
title="Text Generation Demo"
|
24 |
)
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
import requests
|
4 |
import json
|
5 |
+
# from diffusers import StableDiffusionLDM3DPipeline
|
6 |
+
import gradio as gr
|
7 |
+
import torch
|
8 |
+
from PIL import Image
|
9 |
+
import base64
|
10 |
+
from io import BytesIO
|
11 |
+
from tempfile import NamedTemporaryFile
|
12 |
+
from pathlib import Path
|
13 |
+
|
14 |
+
from gradio_client import Client
|
15 |
|
16 |
+
theme = gr.themes.Base(
|
17 |
+
primary_hue=gr.themes.Color(
|
18 |
+
c100="#dbeafe", c200="#bfdbfe", c300="#93c5fd", c400="#60a5fa", c50="#eff6ff", c500="#0054ae", c600="#00377c", c700="#00377c", c800="#1e40af", c900="#1e3a8a", c950="#0a0c2b"),
|
19 |
+
secondary_hue=gr.themes.Color(
|
20 |
+
c100="#dbeafe", c200="#bfdbfe", c300="#93c5fd", c400="#60a5fa", c50="#eff6ff", c500="#0054ae", c600="#0054ae", c700="#0054ae", c800="#1e40af", c900="#1e3a8a", c950="#1d3660"),
|
21 |
+
).set(
|
22 |
+
body_background_fill_dark='*primary_950',
|
23 |
+
body_text_color_dark='#FFFFFF',
|
24 |
+
body_text_color='#000000',
|
25 |
+
border_color_accent='*primary_700',
|
26 |
+
border_color_accent_dark='*neutral_800',
|
27 |
+
block_background_fill_dark='*primary_950',
|
28 |
+
block_border_width='2px',
|
29 |
+
block_border_width_dark='2px',
|
30 |
+
button_primary_background_fill_dark='*primary_500',
|
31 |
+
button_primary_border_color_dark='*primary_500'
|
|
|
|
|
|
|
32 |
)
|
33 |
|
34 |
+
css='''
|
35 |
+
@font-face {
|
36 |
+
font-family: IntelOne;
|
37 |
+
src: url("file/assets/intelone-bodytext-font-family-regular.ttf");
|
38 |
+
}
|
39 |
+
'''
|
40 |
+
|
41 |
+
html_title = '''
|
42 |
+
<table>
|
43 |
+
<tr style="height:150px">
|
44 |
+
<td style="border-bottom:0"><img src="file/assets/intel-labs.png" height="100" width="100"></td>
|
45 |
+
<td style="border-bottom:0; vertical-align:middle">
|
46 |
+
<p style="font-size:xx-large;font-family:IntelOne, Georgia, sans-serif;color: var(--body-text-color);">
|
47 |
+
Cognitive AI:
|
48 |
+
<br>
|
49 |
+
LDM3D: Latent Diffusion Model for 3D
|
50 |
+
</p>
|
51 |
+
</td>
|
52 |
+
<td style="border-bottom:0;"><img src="file/assets/gaudi.png" width="100" height="100"></td>
|
53 |
+
<td style="border-bottom:0;"><img src="file/assets/xeon.png" width="100" height="100"></td>
|
54 |
+
</tr>
|
55 |
+
</table>
|
56 |
+
|
57 |
+
'''
|
58 |
+
|
59 |
+
client = Client("http://198.175.88.247:17810/")
|
60 |
+
|
61 |
+
def generate(
|
62 |
+
prompt: str,
|
63 |
+
negative_prompt: str,
|
64 |
+
guidance_scale: float = 5.0,
|
65 |
+
seed: int = 0,
|
66 |
+
randomize_seed: bool = True,
|
67 |
+
):
|
68 |
+
|
69 |
+
result = client.predict(
|
70 |
+
prompt, # str in 'Prompt' Textbox component
|
71 |
+
negative_prompt, # str in 'Negative Prompt' Textbox component
|
72 |
+
guidance_scale, # int | float (numeric value between 0 and 10) in 'Guidance Scale' Slider component
|
73 |
+
seed, # int | float (numeric value between 0 and 18446744073709551615) in 'Seed' Slider component
|
74 |
+
randomize_seed, # bool in 'Randomize Seed' Checkbox component
|
75 |
+
False, # bool in 'Upscale' Checkbox component
|
76 |
+
fn_index=1
|
77 |
+
)
|
78 |
+
|
79 |
+
return result
|
80 |
+
|
81 |
+
with gr.Blocks(theme=theme, css=css) as demo:
|
82 |
+
gr.HTML(value=html_title)
|
83 |
+
gr.Markdown(
|
84 |
+
"""
|
85 |
+
[Model card](https://huggingface.co/Intel/ldm3d-pano<br>)
|
86 |
+
[Diffusers docs](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/ldm3d_diffusion)
|
87 |
+
For better results, specify "360 view of" or "panoramic view of" in the prompt
|
88 |
+
|
89 |
+
"""
|
90 |
+
)
|
91 |
+
with gr.Row():
|
92 |
+
with gr.Column(scale=1):
|
93 |
+
prompt = gr.Textbox(label="Prompt")
|
94 |
+
negative_prompt = gr.Textbox(label="Negative Prompt")
|
95 |
+
guidance_scale = gr.Slider(
|
96 |
+
label="Guidance Scale", minimum=0, maximum=10, step=0.1, value=5.0
|
97 |
+
)
|
98 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
99 |
+
seed = gr.Slider(label="Seed", minimum=0,
|
100 |
+
maximum=2**64 - 1, step=1)
|
101 |
+
generated_seed = gr.Number(label="Generated Seed")
|
102 |
+
markdown = gr.Markdown(label="Output Box")
|
103 |
+
with gr.Row():
|
104 |
+
new_btn = gr.Button("New Image")
|
105 |
+
with gr.Column(scale=2):
|
106 |
+
html = gr.HTML()
|
107 |
+
with gr.Row():
|
108 |
+
rgb = gr.Image(label="RGB Image", type="filepath")
|
109 |
+
depth = gr.Image(label="Depth Image", type="filepath")
|
110 |
+
|
111 |
+
gr.Examples(
|
112 |
+
examples=[
|
113 |
+
["360 view of a large bedroom", "", 7.0, 42, False]],
|
114 |
+
inputs=[prompt, negative_prompt, guidance_scale, seed, randomize_seed],
|
115 |
+
outputs=[rgb, depth, generated_seed, html],
|
116 |
+
fn=generate,
|
117 |
+
cache_examples=False)
|
118 |
+
|
119 |
+
new_btn.click(
|
120 |
+
fn=generate,
|
121 |
+
inputs=[prompt, negative_prompt, guidance_scale, seed, randomize_seed],
|
122 |
+
outputs=[rgb, depth, generated_seed, html],
|
123 |
+
)
|
124 |
+
|
125 |
+
demo.launch(
|
126 |
+
allowed_paths=["assets/", "static/"]
|
127 |
+
)
|
assets/.ipynb_checkpoints/video_search_app_title-checkpoint.png
ADDED
Git LFS Details
|
assets/gaudi.png
ADDED
Git LFS Details
|
assets/intel-labs.png
ADDED
Git LFS Details
|
assets/intelone-bodytext-font-family-regular.ttf
ADDED
Binary file (77.4 kB). View file
|
|
assets/video_search_app_title.png
ADDED
Git LFS Details
|
assets/video_search_app_ui.png
ADDED
Git LFS Details
|
assets/xeon.png
ADDED
Git LFS Details
|
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
|
2 |
-
|
3 |
transformers
|
4 |
accelerate
|
5 |
Pillow
|
6 |
numpy
|
7 |
-
torch
|
|
|
1 |
+
gradio==4.36.1
|
2 |
+
diffusers
|
3 |
transformers
|
4 |
accelerate
|
5 |
Pillow
|
6 |
numpy
|
7 |
+
torch
|