Barath05 commited on
Commit
a391056
·
verified ·
1 Parent(s): e04074c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -9,7 +9,6 @@ from gradio_client import Client, file
9
 
10
  # --- CONFIGURATION ---
11
  # We use the Gradio Client to connect to the official GPU-powered Space
12
- # This bypasses the "404" API error.
13
  REMOTE_MODEL_ID = "stabilityai/TripoSR"
14
 
15
  def photo_to_sketch(image):
@@ -59,13 +58,12 @@ def generate_3d_avatar(sketch_image, height, weight, muscle, gender, breast):
59
  client = Client(REMOTE_MODEL_ID)
60
 
61
  # 3. Send the image to the remote model
62
- # Note: TripoSR inputs are usually [Image, Remove Background Bool, Foreground Ratio]
63
  print("-> Sending request to remote GPU...")
64
  result_path = client.predict(
65
  file(sketch_path), # The image file
66
- False, # Do not remove background (our sketch is already clean)
67
- 0.85, # Foreground ratio (default)
68
- api_name="/generate" # Standard endpoint name for TripoSR
69
  )
70
 
71
  print(f"-> Success! Received 3D model at: {result_path}")
@@ -88,12 +86,14 @@ with gr.Blocks(title="SketchToLife") as demo:
88
 
89
  with gr.Column():
90
  gr.Markdown("### Customize 3D Body")
91
- # These dropdowns are placeholders for the prompt logic (if we were using text-to-3d),
92
- # but TripoSR is purely Image-to-3D. We keep them for UI layout.
 
93
  h = gr.Dropdown(["short", "average", "tall", "giant"], value="average", label="Height")
94
  w = gr.Dropdown(["slim", "average", "curvy", "heavy"], value="average", label="Weight")
95
  m = gr.Dropdown(["slim", "fit", "muscular", "bodybuilder"], value="fit", label="Muscle")
96
  g = gr.Radio(["male", "female", "neutral"], value="neutral", label="Gender")
 
97
 
98
  btn2 = gr.Button("Generate 3D Model", variant="primary", size="lg")
99
 
@@ -102,7 +102,9 @@ with gr.Blocks(title="SketchToLife") as demo:
102
  download = gr.File(label="Download .GLB")
103
 
104
  btn1.click(photo_to_sketch, inputs=inp, outputs=out_sketch)
105
- btn2.click(generate_3d_avatar, inputs=[out_sketch, h, w, m, g], outputs=[view3d, download])
 
 
106
 
107
  if __name__ == "__main__":
108
  demo.launch(
 
9
 
10
  # --- CONFIGURATION ---
11
  # We use the Gradio Client to connect to the official GPU-powered Space
 
12
  REMOTE_MODEL_ID = "stabilityai/TripoSR"
13
 
14
  def photo_to_sketch(image):
 
58
  client = Client(REMOTE_MODEL_ID)
59
 
60
  # 3. Send the image to the remote model
 
61
  print("-> Sending request to remote GPU...")
62
  result_path = client.predict(
63
  file(sketch_path), # The image file
64
+ False, # Do not remove background
65
+ 0.85, # Foreground ratio
66
+ api_name="/generate"
67
  )
68
 
69
  print(f"-> Success! Received 3D model at: {result_path}")
 
86
 
87
  with gr.Column():
88
  gr.Markdown("### Customize 3D Body")
89
+ # Note: TripoSR is purely image-to-3D, so these dropdowns
90
+ # are currently just placeholders in this specific workflow,
91
+ # but we keep them to prevent the code from crashing.
92
  h = gr.Dropdown(["short", "average", "tall", "giant"], value="average", label="Height")
93
  w = gr.Dropdown(["slim", "average", "curvy", "heavy"], value="average", label="Weight")
94
  m = gr.Dropdown(["slim", "fit", "muscular", "bodybuilder"], value="fit", label="Muscle")
95
  g = gr.Radio(["male", "female", "neutral"], value="neutral", label="Gender")
96
+ b = gr.Dropdown(["small", "medium", "large"], value="medium", label="Breast/Form")
97
 
98
  btn2 = gr.Button("Generate 3D Model", variant="primary", size="lg")
99
 
 
102
  download = gr.File(label="Download .GLB")
103
 
104
  btn1.click(photo_to_sketch, inputs=inp, outputs=out_sketch)
105
+
106
+ # --- FIXED LINE BELOW: Added 'b' back to inputs ---
107
+ btn2.click(generate_3d_avatar, inputs=[out_sketch, h, w, m, g, b], outputs=[view3d, download])
108
 
109
  if __name__ == "__main__":
110
  demo.launch(