Spaces:
Running
Running
| import gradio as gr | |
| from gradio_client import Client, handle_file | |
| # Dono functions jo background mein asli AI spaces ko call karenge | |
| def text_to_3d_api(text_prompt): | |
| if not text_prompt: | |
| return None, "Please enter a text prompt!" | |
| try: | |
| # Tripo3D ya InstantMesh ka public client use kar rahe hain | |
| client = Client("jiawei011/InstantMesh") | |
| # Pehle text se image banti hai ya direct 3D mesh processing hoti hai | |
| result = client.predict( | |
| text_prompt=text_prompt, | |
| api_name="/generate_3d" | |
| ) | |
| return result, "Text-to-3D Model Generated Successfully!" | |
| except Exception as e: | |
| return None, f"Error: {str(e)}. (Tip: Try again or check Hugging Face traffic)." | |
| def image_to_3d_api(input_image): | |
| if input_image is None: | |
| return None, "Please upload an image first!" | |
| try: | |
| # Stable Fast 3D ki high-speed API ko call kar rahe hain | |
| client = Client("stabilityai/stable-fast-3d") | |
| result = client.predict( | |
| input_image=handle_file(input_image), | |
| api_name="/process" | |
| ) | |
| # result mein .glb ya .obj 3D file ka path aata hai | |
| return result, "Image-to-3D Asset Created Successfully!" | |
| except Exception as e: | |
| return None, f"Error: {str(e)}. (Tip: Free API slots might be busy)." | |
| # V.O.I.D. Advanced Interface Design | |
| with gr.Blocks(theme=gr.themes.Monochrome()) as demo: | |
| gr.Markdown("# 🌌 V.O.I.D. Ultimate 3D Engine") | |
| gr.Markdown("### Official 3D Asset Creator for T-Gang | Free Fire MAX Optimized") | |
| with gr.Tabs(): | |
| # TAB 1: TEXT TO 3D | |
| with gr.TabItem("✨ Text to 3D"): | |
| gr.Markdown("### Enter your prompt to generate 3D structure") | |
| txt_input = gr.Textbox(label="Text Prompt", placeholder="e.g., Satoru Gojo realistic 3D model...") | |
| txt_btn = gr.Button("Generate 3D from Text", variant="primary") | |
| txt_output_model = gr.Model3D(label="3D Preview") | |
| txt_status = gr.Textbox(label="System Status", interactive=False) | |
| txt_btn.click(fn=text_to_3d_api, inputs=txt_input, outputs=[txt_output_model, txt_status]) | |
| # TAB 2: IMAGE TO 3D | |
| with gr.TabItem("🖼️ Image to 3D"): | |
| gr.Markdown("### Upload an image to instantly convert into 3D Mesh") | |
| img_input = gr.Image(type="filepath", label="Upload Character/Object Image") | |
| img_btn = gr.Button("Convert Image to 3D", variant="primary") | |
| img_output_model = gr.Model3D(label="3D Preview") | |
| img_status = gr.Textbox(label="System Status", interactive=False) | |
| img_btn.click(fn=image_to_3d_api, inputs=img_input, outputs=[img_output_model, img_status]) | |
| gr.Markdown("---") | |
| gr.Markdown("⚠️ **V.O.I.D. Core Rules:**\n* **JJK Supremacy:** Any character models or simulation assets created here obey the absolute law—Jujutsu Kaisen always wins.\n* **Game Ready:** Models are light and compatible with Free Fire MAX (The world's most popular game).") | |
| demo.launch() | |