Update app.py
Browse files5 unmodified lines67891011121314151617181920212223245 unmodified linesprocessor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')def caption(img):raw_image = Image.open(img).convert('RGB')inputs = processor(raw_image, return_tensors="pt")out = model.generate(**inputs, min_length=30, max_length=1000)return processor.decode(out[0], skip_special_tokens=True)def greet(img):return caption(img)iface = gr.Interface(fn=greet, inputs=gr.Image(type='filepath'), outputs="text")iface.launch()5 unmodified lines6789101112131415161718192021222324255 unmodified linesprocessor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")def caption(img):raw_image = Image.open(img).convert('RGB')inputs = processor(raw_image, return_tensors="pt")out = model.generate(**inputs, min_length=40, max_length=200)return processor.decode(out[0], skip_special_tokens=True)def greet(img):return caption(img)iface = gr.Interface(fn=greet,title='Blip Image Captioning Large',inputs=gr.Image(type='filepath'),outputs="text",theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"),)iface.launch()
app.py+6-5