|
import gradio as gr |
|
from transformers import AutoModel, AutoProcessor |
|
from PIL import Image |
|
import torch |
|
|
|
|
|
try: |
|
model = AutoModel.from_pretrained("zxhezexin/openlrm-mix-large-1.1") |
|
processor = AutoProcessor.from_pretrained("zxhezexin/openlrm-mix-large-1.1") |
|
except Exception as e: |
|
print(f"Error loading model or processor: {e}") |
|
|
|
|
|
def image_to_3d(image): |
|
try: |
|
|
|
inputs = processor(images=image, return_tensors="pt") |
|
|
|
|
|
with torch.no_grad(): |
|
outputs = model(**inputs) |
|
|
|
|
|
return "3D model generated!" |
|
except Exception as e: |
|
return f"Error during inference: {str(e)}" |
|
|
|
|
|
interface = gr.Interface( |
|
fn=image_to_3d, |
|
inputs=gr.Image(type="pil"), |
|
outputs="text", |
|
title="OpenLRM Mix-Large 1.1 - Image to 3D", |
|
description="Upload an image to generate a 3D model using OpenLRM Mix-Large 1.1." |
|
) |
|
|
|
|
|
interface.launch() |
|
|