ahmetyaylalioglu commited on
Commit
8ccf912
·
verified ·
1 Parent(s): 9b2337b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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 regardless of the availability of CUDA
9
  device = "cpu"
10
 
11
- # Update model loading and processing to work on CPU
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 Interface with Click Events
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=["image", gr.Image(shape=(512, 512), image_mode='RGB', source="canvas", tool="sketch")],
 
 
 
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)