Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,19 +27,20 @@ feature_extractor = ViTFeatureExtractor.from_pretrained(repo_name)
|
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained(repo_name)
|
| 28 |
model = VisionEncoderDecoderModel.from_pretrained(repo_name)
|
| 29 |
|
| 30 |
-
def get_quote(
|
| 31 |
#reader = easyocr.Reader(['en'])
|
| 32 |
#image = Image.open(image_1,mode = 'r')
|
| 33 |
#image = Image.open(image_1)
|
| 34 |
|
| 35 |
#image_2 = Image.open(requests.get(image_1, stream=True).raw)
|
| 36 |
|
| 37 |
-
image = Image.open(image_path)
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
##############
|
| 45 |
pixel_values = feature_extractor(image, return_tensors="pt").pixel_values
|
|
@@ -59,7 +60,8 @@ def get_quote(image_path):
|
|
| 59 |
#import gradio as gr
|
| 60 |
title = "Image to text generation"
|
| 61 |
|
| 62 |
-
demo = gr.Interface(fn=get_quote, inputs
|
|
|
|
| 63 |
if __name__ == "__main__":
|
| 64 |
|
| 65 |
-
demo.launch()
|
|
|
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained(repo_name)
|
| 28 |
model = VisionEncoderDecoderModel.from_pretrained(repo_name)
|
| 29 |
|
| 30 |
+
def get_quote(url):
|
| 31 |
#reader = easyocr.Reader(['en'])
|
| 32 |
#image = Image.open(image_1,mode = 'r')
|
| 33 |
#image = Image.open(image_1)
|
| 34 |
|
| 35 |
#image_2 = Image.open(requests.get(image_1, stream=True).raw)
|
| 36 |
|
| 37 |
+
#image = Image.open(image_path)
|
| 38 |
|
| 39 |
+
#url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 40 |
+
with Image.open(requests.get(url, stream=True).raw) as image:
|
| 41 |
+
|
| 42 |
+
image.save("cats.png")
|
| 43 |
+
#preds = predict(image)
|
| 44 |
|
| 45 |
##############
|
| 46 |
pixel_values = feature_extractor(image, return_tensors="pt").pixel_values
|
|
|
|
| 60 |
#import gradio as gr
|
| 61 |
title = "Image to text generation"
|
| 62 |
|
| 63 |
+
demo = gr.Interface(fn=get_quote, inputs=gr.inputs.Image(type="pil"), outputs=['text'],title = title, description = "Import an image file and get text from it" ,cache_examples=False, enable_queue=True).launch()
|
| 64 |
+
#inputs = "image"
|
| 65 |
if __name__ == "__main__":
|
| 66 |
|
| 67 |
+
demo.launch(debug=True, cache_examples=True)
|