File size: 1,210 Bytes
c15294b
 
 
 
 
 
e9207f1
 
 
 
 
c15294b
 
 
e9207f1
 
 
 
 
 
 
 
 
 
 
 
c15294b
 
 
 
 
e9207f1
 
 
c15294b
 
e9207f1
c15294b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr
from transformers import AutoModel, AutoProcessor
from PIL import Image
import torch

# Load model and processor
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}")

# Define function to generate 3D output from 2D image
def image_to_3d(image):
    try:
        # Preprocess the input image
        inputs = processor(images=image, return_tensors="pt")
        
        # Run inference
        with torch.no_grad():
            outputs = model(**inputs)
        
        # Placeholder return, replace this with actual 3D visualization
        return "3D model generated!"  
    except Exception as e:
        return f"Error during inference: {str(e)}"

# Gradio interface
interface = gr.Interface(
    fn=image_to_3d,
    inputs=gr.Image(type="pil"),
    outputs="text",  # Placeholder output (you can modify this for 3D)
    title="OpenLRM Mix-Large 1.1 - Image to 3D",
    description="Upload an image to generate a 3D model using OpenLRM Mix-Large 1.1."
)

# Launch the Gradio interface
interface.launch()