Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,17 @@ import torch
|
|
5 |
import requests
|
6 |
from io import BytesIO
|
7 |
|
8 |
-
# Load model and processor
|
9 |
try:
|
10 |
model = AutoModel.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
11 |
processor = AutoProcessor.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
12 |
except Exception as e:
|
13 |
print(f"Error loading model or processor: {e}")
|
14 |
|
15 |
-
# Example image URL (
|
16 |
-
example_image_url = "https://
|
17 |
|
18 |
-
#
|
19 |
def load_example_image():
|
20 |
try:
|
21 |
response = requests.get(example_image_url)
|
@@ -35,23 +35,23 @@ def image_to_3d(image):
|
|
35 |
with torch.no_grad():
|
36 |
outputs = model(**inputs)
|
37 |
|
38 |
-
# Placeholder return, replace this with actual 3D visualization
|
39 |
-
return "3D model generated!"
|
40 |
except Exception as e:
|
41 |
return f"Error during inference: {str(e)}"
|
42 |
|
43 |
-
# Gradio interface
|
44 |
example_image = load_example_image()
|
45 |
|
|
|
46 |
interface = gr.Interface(
|
47 |
fn=image_to_3d,
|
48 |
inputs=gr.Image(type="pil", label="Upload an Image or use Example"),
|
49 |
-
outputs="text", # Placeholder output (
|
50 |
title="OpenLRM Mix-Large 1.1 - Image to 3D",
|
51 |
description="Upload an image to generate a 3D model using OpenLRM Mix-Large 1.1.",
|
52 |
-
examples=[[example_image]] if example_image else None # Include the example image
|
53 |
)
|
54 |
|
55 |
# Launch the Gradio interface
|
56 |
interface.launch()
|
57 |
-
|
|
|
5 |
import requests
|
6 |
from io import BytesIO
|
7 |
|
8 |
+
# Load model and processor from Hugging Face
|
9 |
try:
|
10 |
model = AutoModel.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
11 |
processor = AutoProcessor.from_pretrained("zxhezexin/openlrm-mix-large-1.1")
|
12 |
except Exception as e:
|
13 |
print(f"Error loading model or processor: {e}")
|
14 |
|
15 |
+
# Example image URL (replace this with a suitable example)
|
16 |
+
example_image_url = "https://huggingface.co/datasets/nateraw/image-folder/resolve/main/example_1.png"
|
17 |
|
18 |
+
# Function to load example image from URL
|
19 |
def load_example_image():
|
20 |
try:
|
21 |
response = requests.get(example_image_url)
|
|
|
35 |
with torch.no_grad():
|
36 |
outputs = model(**inputs)
|
37 |
|
38 |
+
# Placeholder return, replace this with actual 3D visualization logic
|
39 |
+
return "3D model generated from input image!"
|
40 |
except Exception as e:
|
41 |
return f"Error during inference: {str(e)}"
|
42 |
|
43 |
+
# Load the example image for the Gradio interface
|
44 |
example_image = load_example_image()
|
45 |
|
46 |
+
# Gradio interface setup
|
47 |
interface = gr.Interface(
|
48 |
fn=image_to_3d,
|
49 |
inputs=gr.Image(type="pil", label="Upload an Image or use Example"),
|
50 |
+
outputs="text", # Placeholder output (replace with 3D rendering if needed)
|
51 |
title="OpenLRM Mix-Large 1.1 - Image to 3D",
|
52 |
description="Upload an image to generate a 3D model using OpenLRM Mix-Large 1.1.",
|
53 |
+
examples=[[example_image]] if example_image else None # Include the example image if loaded
|
54 |
)
|
55 |
|
56 |
# Launch the Gradio interface
|
57 |
interface.launch()
|
|