chris999 commited on
Commit
c51c4c7
·
1 Parent(s): d5fecd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -18
app.py CHANGED
@@ -1,21 +1,4 @@
1
  import gradio as gr
2
- def segment(image):
3
- pass # Implement your image segmentation model here...
4
- from PIL import Image
5
- import requests
6
-
7
- from transformers import CLIPProcessor, CLIPModel
8
-
9
- model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
10
- processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
11
-
12
- #url = "http://images.cocodataset.org/val2017/000000039769.jpg"
13
- image = Image.open(requests.get(url, stream=True).raw)
14
-
15
- inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
16
-
17
- outputs = model(**inputs)
18
- logits_per_image = outputs.logits_per_image # this is the image-text similarity score
19
- probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
20
 
21
  gr.Interface(fn=segment, inputs="image", outputs="image").launch()
 
1
  import gradio as gr
2
+ #Salesforce/BLIP
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  gr.Interface(fn=segment, inputs="image", outputs="image").launch()