Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModel, AutoProcessor
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
# Load model and processor
|
| 7 |
+
model = AutoModel.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
| 8 |
+
processor = AutoProcessor.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
| 9 |
+
|
| 10 |
+
# Define function to generate 3D output from 2D image
|
| 11 |
+
def image_to_3d(image):
|
| 12 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 13 |
+
with torch.no_grad():
|
| 14 |
+
outputs = model(**inputs)
|
| 15 |
+
# This is placeholder logic; you'd need to process the outputs appropriately
|
| 16 |
+
return "3D Output Generated" # Replace with actual visualization code
|
| 17 |
+
|
| 18 |
+
# Gradio interface
|
| 19 |
+
interface = gr.Interface(
|
| 20 |
+
fn=image_to_3d,
|
| 21 |
+
inputs=gr.Image(type="pil"),
|
| 22 |
+
outputs="text", # Replace with "3D" if you can visualize the output
|
| 23 |
+
title="OpenLRM Mix-Large 1.1 - Image to 3D"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
interface.launch()
|