Delete README.md
Browse files
README.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
library_name: transformers
|
| 3 |
-
license: apache-2.0
|
| 4 |
-
pipeline_tag: image-to-text
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
# BLIP-Image-to-recip
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
# Inference code
|
| 12 |
-
|
| 13 |
-
---
|
| 14 |
-
|
| 15 |
-
import requests
|
| 16 |
-
from PIL import Image
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
from transformers import BlipForConditionalGeneration, AutoProcessor
|
| 21 |
-
|
| 22 |
-
img_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQuFg4LTHUattLGPU0kLzYpBGHRtuqgJY8Gho3uZe_cg&s'
|
| 23 |
-
image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
|
| 24 |
-
|
| 25 |
-
model = BlipForConditionalGeneration.from_pretrained("Fatehmujtaba/BLIP-Image-to-recipe").to(device)
|
| 26 |
-
processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
inputs = processor(images=image, return_tensors="pt").to(device)
|
| 30 |
-
pixel_values = inputs.pixel_values
|
| 31 |
-
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
|
| 32 |
-
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 33 |
-
|
| 34 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|