Spaces:
Running
on
Zero
Running
on
Zero
bennyguo
commited on
Commit
·
fc91ae0
1
Parent(s):
af15ec4
update description
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# --- Environment Variables Used ---
|
| 2 |
-
#
|
| 3 |
# TRIPOSG_CODE_PATH: Absolute path to a local directory containing the checked-out TripoSG repository (scribble branch).
|
| 4 |
# GITHUB_TOKEN: A GitHub token used for cloning the TripoSG repo if TRIPOSG_CODE_PATH is not provided.
|
| 5 |
# WEIGHTS_PATH: Absolute path to a local directory containing the TripoSG-scribble model weights.
|
|
@@ -257,7 +257,7 @@ class WaifuDiffusionInterrogator:
|
|
| 257 |
new_image = Image.new('RGBA', image.size, 'WHITE')
|
| 258 |
new_image.paste(image, mask=image)
|
| 259 |
image = new_image.convert('RGB')
|
| 260 |
-
|
| 261 |
image = np.asarray(image)
|
| 262 |
image = image[:, :, ::-1]
|
| 263 |
|
|
@@ -327,13 +327,13 @@ def generate_3d(scribble_image_dict, prompt, scribble_confidence, text_confidenc
|
|
| 327 |
input_prompt = generated_prompt
|
| 328 |
else:
|
| 329 |
print("WD14 tagging did not produce tags above threshold.")
|
| 330 |
-
input_prompt = "object" # Fallback prompt
|
| 331 |
else:
|
| 332 |
print("WD14 tagging failed or tagger not initialized.")
|
| 333 |
-
input_prompt = "object" # Fallback prompt
|
| 334 |
except Exception as e:
|
| 335 |
print(f"Error during WD14 tagging: {e}")
|
| 336 |
-
input_prompt = "object" # Fallback prompt
|
| 337 |
else:
|
| 338 |
print(f"Using user provided prompt: {input_prompt}")
|
| 339 |
# --- End Prompt Handling ---
|
|
@@ -398,20 +398,27 @@ def generate_3d(scribble_image_dict, prompt, scribble_confidence, text_confidenc
|
|
| 398 |
# Create the Gradio interface
|
| 399 |
with gr.Blocks() as demo:
|
| 400 |
gr.Markdown("# TripoSG Scribble!!")
|
| 401 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
with gr.Row():
|
| 403 |
with gr.Column(scale=1):
|
| 404 |
image_input = gr.ImageEditor(
|
| 405 |
label="Scribble Input (Draw Black on White)",
|
| 406 |
value=initial_value,
|
| 407 |
image_mode="RGB",
|
| 408 |
-
brush=gr.Brush(default_color="#000000", color_mode="fixed", default_size=5),
|
| 409 |
interactive=True,
|
| 410 |
-
eraser=gr.Brush(default_color="#FFFFFF", color_mode="fixed", default_size=20)
|
| 411 |
)
|
| 412 |
prompt_input = gr.Textbox(label="Prompt", placeholder="e.g., a cute cat wearing a hat")
|
| 413 |
confidence_input = gr.Slider(minimum=0.0, maximum=1.0, value=0.4, step=0.05, label="Scribble Confidence")
|
| 414 |
-
prompt_confidence_input = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, step=0.05, label="Prompt Confidence")
|
| 415 |
seed_input = gr.Number(label="Seed", value=0, precision=0) # Added Seed input back
|
| 416 |
with gr.Row():
|
| 417 |
submit_button = gr.Button("Generate 3D Model", variant="primary", scale=1)
|
|
|
|
| 1 |
# --- Environment Variables Used ---
|
| 2 |
+
# DISABLE_ZEROGPU: Set to 'true' or '1' to disable @spaces.GPU decorator (for Hugging Face Spaces).
|
| 3 |
# TRIPOSG_CODE_PATH: Absolute path to a local directory containing the checked-out TripoSG repository (scribble branch).
|
| 4 |
# GITHUB_TOKEN: A GitHub token used for cloning the TripoSG repo if TRIPOSG_CODE_PATH is not provided.
|
| 5 |
# WEIGHTS_PATH: Absolute path to a local directory containing the TripoSG-scribble model weights.
|
|
|
|
| 257 |
new_image = Image.new('RGBA', image.size, 'WHITE')
|
| 258 |
new_image.paste(image, mask=image)
|
| 259 |
image = new_image.convert('RGB')
|
| 260 |
+
|
| 261 |
image = np.asarray(image)
|
| 262 |
image = image[:, :, ::-1]
|
| 263 |
|
|
|
|
| 327 |
input_prompt = generated_prompt
|
| 328 |
else:
|
| 329 |
print("WD14 tagging did not produce tags above threshold.")
|
| 330 |
+
input_prompt = "3d object" # Fallback prompt
|
| 331 |
else:
|
| 332 |
print("WD14 tagging failed or tagger not initialized.")
|
| 333 |
+
input_prompt = "3d object" # Fallback prompt
|
| 334 |
except Exception as e:
|
| 335 |
print(f"Error during WD14 tagging: {e}")
|
| 336 |
+
input_prompt = "3d object" # Fallback prompt
|
| 337 |
else:
|
| 338 |
print(f"Using user provided prompt: {input_prompt}")
|
| 339 |
# --- End Prompt Handling ---
|
|
|
|
| 398 |
# Create the Gradio interface
|
| 399 |
with gr.Blocks() as demo:
|
| 400 |
gr.Markdown("# TripoSG Scribble!!")
|
| 401 |
+
gr.Markdown("""
|
| 402 |
+
[](https://github.com/VAST-AI-Research/TripoSG)
|
| 403 |
+
|
| 404 |
+
### Fast 3D shape prototyping with simple scribble and text prompt. Presented by [Tripo](https://www.tripo3d.ai/).
|
| 405 |
+
|
| 406 |
+
- For local deployment, simply clone this space, set up the environment and run with DISABLE_ZEROGPU=1.
|
| 407 |
+
- Feel free to tune the scribble confidence to balance fidelity and alignment :)
|
| 408 |
+
""")
|
| 409 |
with gr.Row():
|
| 410 |
with gr.Column(scale=1):
|
| 411 |
image_input = gr.ImageEditor(
|
| 412 |
label="Scribble Input (Draw Black on White)",
|
| 413 |
value=initial_value,
|
| 414 |
image_mode="RGB",
|
| 415 |
+
brush=gr.Brush(default_color="#000000", color_mode="fixed", default_size=5),
|
| 416 |
interactive=True,
|
| 417 |
+
eraser=gr.Brush(default_color="#FFFFFF", color_mode="fixed", default_size=20)
|
| 418 |
)
|
| 419 |
prompt_input = gr.Textbox(label="Prompt", placeholder="e.g., a cute cat wearing a hat")
|
| 420 |
confidence_input = gr.Slider(minimum=0.0, maximum=1.0, value=0.4, step=0.05, label="Scribble Confidence")
|
| 421 |
+
prompt_confidence_input = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, step=0.05, label="Prompt Confidence")
|
| 422 |
seed_input = gr.Number(label="Seed", value=0, precision=0) # Added Seed input back
|
| 423 |
with gr.Row():
|
| 424 |
submit_button = gr.Button("Generate 3D Model", variant="primary", scale=1)
|