Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ 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 |
try:
|
@@ -10,6 +12,19 @@ try:
|
|
10 |
except Exception as e:
|
11 |
print(f"Error loading model or processor: {e}")
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Define function to generate 3D output from 2D image
|
14 |
def image_to_3d(image):
|
15 |
try:
|
@@ -26,13 +41,17 @@ def image_to_3d(image):
|
|
26 |
return f"Error during inference: {str(e)}"
|
27 |
|
28 |
# Gradio interface
|
|
|
|
|
29 |
interface = gr.Interface(
|
30 |
fn=image_to_3d,
|
31 |
-
inputs=gr.Image(type="pil"),
|
32 |
outputs="text", # Placeholder output (you can modify this for 3D)
|
33 |
title="OpenLRM Mix-Large 1.1 - Image to 3D",
|
34 |
-
description="Upload an image to generate a 3D model using OpenLRM Mix-Large 1.1."
|
|
|
35 |
)
|
36 |
|
37 |
# Launch the Gradio interface
|
38 |
interface.launch()
|
|
|
|
2 |
from transformers import AutoModel, AutoProcessor
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
+
import requests
|
6 |
+
from io import BytesIO
|
7 |
|
8 |
# Load model and processor
|
9 |
try:
|
|
|
12 |
except Exception as e:
|
13 |
print(f"Error loading model or processor: {e}")
|
14 |
|
15 |
+
# Example image URL (change this to a suitable 2D image URL)
|
16 |
+
example_image_url = "https://example.com/path-to-your-example-image.jpg"
|
17 |
+
|
18 |
+
# Load example image
|
19 |
+
def load_example_image():
|
20 |
+
try:
|
21 |
+
response = requests.get(example_image_url)
|
22 |
+
image = Image.open(BytesIO(response.content))
|
23 |
+
return image
|
24 |
+
except Exception as e:
|
25 |
+
print(f"Error loading example image: {e}")
|
26 |
+
return None
|
27 |
+
|
28 |
# Define function to generate 3D output from 2D image
|
29 |
def image_to_3d(image):
|
30 |
try:
|
|
|
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 (you can modify this for 3D)
|
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 |
+
|