Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,11 @@ from transformers import pipeline, AutoModelForVision2Seq, AutoProcessor
|
|
4 |
import torch
|
5 |
|
6 |
# Load the OpenGVLab/InternVL-Chat-V1-5 model and processor
|
7 |
-
|
8 |
-
model =
|
9 |
|
10 |
# Load the Llama3 model for text processing
|
11 |
-
llama_model = pipeline("text2text-generation", model="llama3")
|
12 |
|
13 |
def process_image(image):
|
14 |
# Process the image to extract the recipe using OpenGVLab
|
@@ -18,25 +18,17 @@ def process_image(image):
|
|
18 |
|
19 |
return extracted_text
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
def app(image, adjustment):
|
28 |
-
extracted_text = process_image(image)
|
29 |
-
adjusted_recipe = adjust_recipe(extracted_text, adjustment)
|
30 |
-
return adjusted_recipe
|
31 |
-
|
32 |
-
# Create the Gradio interface
|
33 |
-
interface = gr.Interface(
|
34 |
-
fn=app,
|
35 |
-
inputs=[gr.inputs.Image(type="file"), gr.inputs.Dropdown(["double", "halve"])],
|
36 |
outputs="text",
|
37 |
-
title="Recipe
|
38 |
-
description="Upload an image of a recipe
|
39 |
)
|
40 |
|
|
|
41 |
if __name__ == "__main__":
|
42 |
-
interface.launch()
|
|
|
4 |
import torch
|
5 |
|
6 |
# Load the OpenGVLab/InternVL-Chat-V1-5 model and processor
|
7 |
+
from transformers import AutoModel
|
8 |
+
model = AutoModel.from_pretrained("OpenGVLab/InternVL-Chat-V1-5", trust_remote_code=True)
|
9 |
|
10 |
# Load the Llama3 model for text processing
|
11 |
+
#llama_model = pipeline("text2text-generation", model="llama3")
|
12 |
|
13 |
def process_image(image):
|
14 |
# Process the image to extract the recipe using OpenGVLab
|
|
|
18 |
|
19 |
return extracted_text
|
20 |
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=process_image,
|
23 |
+
inputs=[
|
24 |
+
gr.components.Image(type="filepath", label="Recipe Image"),
|
25 |
+
#gr.components.Radio(choices=["Double", "Triple", "Half", "Third"], label="Action")
|
26 |
+
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
outputs="text",
|
28 |
+
title="Recipe Modifier",
|
29 |
+
description="Upload an image of a recipe and choose how to modify the measurements.",
|
30 |
)
|
31 |
|
32 |
+
|
33 |
if __name__ == "__main__":
|
34 |
+
interface.launch(share=True)
|