dcr / test_trellis.py
Desarrollo33's picture
feat: add trellis integration with robust fallback
4caf6af
from gradio_client import Client, handle_file
import time
import os
from PIL import Image
# Use the specific space URL if the name redirects
client = Client("JeffreyXiang/TRELLIS")
# Create a robust dummy image
image_path = "test_vehicle.png"
img = Image.new('RGB', (512, 512), color = 'red')
img.save(image_path)
print(f"Created dummy image at {os.path.abspath(image_path)}")
print("1. Uploading and generating 3D asset...")
try:
result_video = client.predict(
image=handle_file(image_path),
multiimages=[],
seed=0,
ss_guidance_strength=7.5,
ss_sampling_steps=12,
slat_guidance_strength=3.0,
slat_sampling_steps=12,
multiimage_algo="stochastic",
api_name="/image_to_3d"
)
print(f"Generation complete. Result: {result_video}")
print("2. Extracting GLB...")
result_glb = client.predict(
mesh_simplify=0.95,
texture_size=1024,
api_name="/extract_glb"
)
print(f"Extraction complete. Result: {result_glb}")
except Exception as e:
print(f"Error: {e}")