Spaces:
Runtime error
Runtime error
RamAnanth1
commited on
Commit
•
82e1020
1
Parent(s):
1416cc9
Update app.py
Browse files
app.py
CHANGED
@@ -9,26 +9,30 @@ lgm_mini_client = Client("dylanebert/LGM-mini")
|
|
9 |
triposr_client = Client("stabilityai/TripoSR")
|
10 |
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def run(image, model_name):
|
13 |
file_path = "temp.png"
|
14 |
image.save(file_path)
|
15 |
-
print(file_path)
|
16 |
-
model_name = model_name.lower()
|
17 |
if model_name=='lgm-mini':
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
elif model_name=='triposr':
|
25 |
|
26 |
process_result = triposr_client.predict(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
print(type(process_result))
|
32 |
|
33 |
result = triposr_client.predict(
|
34 |
process_result, # filepath in 'Processed Image' Image component
|
@@ -36,28 +40,13 @@ def run(image, model_name):
|
|
36 |
api_name="/generate")
|
37 |
|
38 |
output = result[0]
|
39 |
-
|
40 |
return output
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
model_name = gr.Textbox(label="Model name", show_label=False)
|
49 |
-
run_button = gr.Button("Run")
|
50 |
-
with gr.Column(scale=1):
|
51 |
-
result = gr.Model3D(label="Result", show_label=False)
|
52 |
-
|
53 |
-
run_button.click(
|
54 |
-
fn=run,
|
55 |
-
inputs=[
|
56 |
-
image,
|
57 |
-
model_name
|
58 |
-
],
|
59 |
-
outputs=result,
|
60 |
-
api_name="synthesize"
|
61 |
-
)
|
62 |
|
63 |
demo.launch()
|
|
|
9 |
triposr_client = Client("stabilityai/TripoSR")
|
10 |
|
11 |
|
12 |
+
import gradio as gr
|
13 |
+
import os
|
14 |
+
|
15 |
+
from gradio_client import Client
|
16 |
+
|
17 |
+
lgm_mini_client = Client("dylanebert/LGM-mini")
|
18 |
+
triposr_client = Client("stabilityai/TripoSR")
|
19 |
+
|
20 |
def run(image, model_name):
|
21 |
file_path = "temp.png"
|
22 |
image.save(file_path)
|
|
|
|
|
23 |
if model_name=='lgm-mini':
|
24 |
+
result = lgm_mini_client.predict(
|
25 |
+
file_path, # filepath in 'image' Image component
|
26 |
+
api_name="/run"
|
27 |
+
)
|
28 |
+
output = result
|
|
|
29 |
elif model_name=='triposr':
|
30 |
|
31 |
process_result = triposr_client.predict(
|
32 |
+
file_path, # filepath in 'Input Image' Image component
|
33 |
+
True, # bool in 'Remove Background' Checkbox component
|
34 |
+
0.85, # float (numeric value between 0.5 and 1.0) in 'Foreground Ratio' Slider component
|
35 |
+
api_name="/preprocess")
|
|
|
36 |
|
37 |
result = triposr_client.predict(
|
38 |
process_result, # filepath in 'Processed Image' Image component
|
|
|
40 |
api_name="/generate")
|
41 |
|
42 |
output = result[0]
|
|
|
43 |
return output
|
44 |
+
|
45 |
+
|
46 |
+
demo = gr.Interface(
|
47 |
+
fn=run,
|
48 |
+
inputs=[gr.Image(type="pil"),gr.Textbox("Model Name")],
|
49 |
+
outputs=gr.Model3D(label="3D Model"),
|
50 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
demo.launch()
|