Update app.py
Browse files
app.py
CHANGED
@@ -9,18 +9,8 @@ model_id = "Salesforce/blip-image-captioning-base"
|
|
9 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
10 |
processor = BlipProcessor.from_pretrained(model_id)
|
11 |
|
12 |
-
def parse_input(input):
|
13 |
-
# this is a weblink
|
14 |
-
if isinstance(input, str):
|
15 |
-
image = Image.open(requests.get(input, stream=True).raw).convert('RGB')
|
16 |
-
# otherwise it's an image
|
17 |
-
else:
|
18 |
-
image = Image.open(input).convert("RGB")
|
19 |
-
|
20 |
-
return image
|
21 |
-
|
22 |
def launch(input):
|
23 |
-
image =
|
24 |
inputs = processor(image, return_tensors="pt")
|
25 |
out = model.generate(**inputs)
|
26 |
return processor.decode(out[0], skip_special_tokens=True)
|
|
|
9 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
10 |
processor = BlipProcessor.from_pretrained(model_id)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def launch(input):
|
13 |
+
image = Image.open(requests.get(input, stream=True).raw).convert('RGB')
|
14 |
inputs = processor(image, return_tensors="pt")
|
15 |
out = model.generate(**inputs)
|
16 |
return processor.decode(out[0], skip_special_tokens=True)
|