shaoyent commited on
Commit
6a2a362
1 Parent(s): 61e8035
app.py CHANGED
@@ -1,26 +1,127 @@
1
  import gradio as gr
 
2
  import requests
3
  import json
 
 
 
 
 
 
 
 
 
 
4
 
5
- def text_gen(url, prompt):
6
- headers = {'Content-Type': 'application/json'}
7
- payload = {'inputs': prompt, 'parameters': {'max_new_tokens': 32}}
8
- resp = requests.post(url, data=json.dumps(payload), headers=headers)
9
- return resp.text
10
-
11
- URL = "198.175.88.247"
12
- myport = "80"
13
- g2url = f"http://{URL}:{myport}/generate"
14
-
15
- url_input = gr.Textbox(label="URL", value=g2url, visible=True)
16
- prompt_input = gr.Textbox(label="Prompt", value="Why is the sky purple?", visible=True)
17
- outputs = gr.Textbox(label="Generated Text")
18
-
19
- demo = gr.Interface(
20
- fn=text_gen,
21
- inputs=[url_input, prompt_input],
22
- outputs=[outputs],
23
- title="Text Generation Demo"
24
  )
25
 
26
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

  • SHA256: 54910bc26c26433378ac35d3e45e5d32d2c7f99183f4d21e70180970ef43ab0b
  • Pointer size: 131 Bytes
  • Size of remote file: 372 kB
assets/gaudi.png ADDED

Git LFS Details

  • SHA256: a91810c165d8cdcddb79d013190cdd96bda1642c4eeba4240575ebb7a8d96780
  • Pointer size: 130 Bytes
  • Size of remote file: 12.8 kB
assets/intel-labs.png ADDED

Git LFS Details

  • SHA256: e637278a377a2bfa392178890e16c51d4340c1128af12a6d24f1aa6799b10279
  • Pointer size: 131 Bytes
  • Size of remote file: 109 kB
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

  • SHA256: 54910bc26c26433378ac35d3e45e5d32d2c7f99183f4d21e70180970ef43ab0b
  • Pointer size: 131 Bytes
  • Size of remote file: 372 kB
assets/video_search_app_ui.png ADDED

Git LFS Details

  • SHA256: 9d093a85ad2216c2e78215e078b01ddd06d439c6c9a45ef770a9e5309850b724
  • Pointer size: 132 Bytes
  • Size of remote file: 2.02 MB
assets/xeon.png ADDED

Git LFS Details

  • SHA256: 6cf19d4a29b3ef6749ca950c748fbe6bb97baf02dc75c98cad347964bc9c2293
  • Pointer size: 130 Bytes
  • Size of remote file: 52.2 kB
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
- git+https://https://github.com/huggingface/optimum-habana.[email protected].1
2
- gradio==3.40.1
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