Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,10 @@ from transformers import SamModel, SamProcessor
|
|
5 |
from diffusers import AutoPipelineForInpainting
|
6 |
import torch
|
7 |
|
8 |
-
# Force the model to use CPU
|
9 |
device = "cpu"
|
10 |
|
11 |
-
#
|
12 |
model_name = "facebook/sam-vit-huge"
|
13 |
model = SamModel.from_pretrained(model_name).to(device)
|
14 |
processor = SamProcessor.from_pretrained(model_name)
|
@@ -48,7 +48,7 @@ def inpaint(raw_image, input_mask, prompt, negative_prompt=None, seed=74294536,
|
|
48 |
).images[0]
|
49 |
return image
|
50 |
|
51 |
-
# Gradio
|
52 |
def gradio_interface(image, points):
|
53 |
raw_image = Image.fromarray(image).convert("RGB").resize((512, 512))
|
54 |
mask = get_processed_inputs(raw_image, points)
|
@@ -57,7 +57,10 @@ def gradio_interface(image, points):
|
|
57 |
|
58 |
iface = gr.Interface(
|
59 |
fn=gradio_interface,
|
60 |
-
inputs=[
|
|
|
|
|
|
|
61 |
outputs=["image", "image"]
|
62 |
)
|
63 |
iface.launch(share=True)
|
|
|
5 |
from diffusers import AutoPipelineForInpainting
|
6 |
import torch
|
7 |
|
8 |
+
# Force the model to use CPU
|
9 |
device = "cpu"
|
10 |
|
11 |
+
# Model and Processor setup
|
12 |
model_name = "facebook/sam-vit-huge"
|
13 |
model = SamModel.from_pretrained(model_name).to(device)
|
14 |
processor = SamProcessor.from_pretrained(model_name)
|
|
|
48 |
).images[0]
|
49 |
return image
|
50 |
|
51 |
+
# Updated Gradio interface
|
52 |
def gradio_interface(image, points):
|
53 |
raw_image = Image.fromarray(image).convert("RGB").resize((512, 512))
|
54 |
mask = get_processed_inputs(raw_image, points)
|
|
|
57 |
|
58 |
iface = gr.Interface(
|
59 |
fn=gradio_interface,
|
60 |
+
inputs=[
|
61 |
+
gr.Image(image_mode='RGB', image_shape=(512, 512)),
|
62 |
+
"text" # To allow users to enter points manually or through another input method
|
63 |
+
],
|
64 |
outputs=["image", "image"]
|
65 |
)
|
66 |
iface.launch(share=True)
|