RamAnanth1 commited on
Commit
82e1020
1 Parent(s): 1416cc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -35
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
- result = lgm_mini_client.predict(
19
- file_path, # filepath in 'image' Image component
20
- api_name="/run"
21
- )
22
- output = result
23
-
24
  elif model_name=='triposr':
25
 
26
  process_result = triposr_client.predict(
27
- file_path, # filepath in 'Input Image' Image component
28
- True, # bool in 'Remove Background' Checkbox component
29
- 0.85, # float (numeric value between 0.5 and 1.0) in 'Foreground Ratio' Slider component
30
- api_name="/preprocess")
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
- with gr.Blocks() as demo:
44
- with gr.Group():
45
- with gr.Row(variant='panel'):
46
- with gr.Column(scale=1):
47
- image = gr.Image(label="Input image", show_label=False, type="pil", height=180)
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()