Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import subprocess
|
|
2 |
subprocess.run('pip install -r requirements.txt', shell = True)
|
3 |
|
4 |
import gradio as gr
|
|
|
5 |
import os
|
6 |
from PIL import Image
|
7 |
import numpy as np
|
@@ -21,6 +22,7 @@ from langchain_core.prompts import ChatPromptTemplate
|
|
21 |
from rich.console import Console
|
22 |
from rich.markdown import Markdown
|
23 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
|
24 |
|
25 |
transformers.logging.set_verbosity_error()
|
26 |
|
@@ -34,10 +36,10 @@ def image_to_query(image):
|
|
34 |
|
35 |
output: Query for the LLM
|
36 |
"""
|
37 |
-
|
38 |
#image = cv2.imread(image)
|
39 |
#image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
40 |
-
image = Image.fromarray(image)
|
41 |
|
42 |
model = AutoModelForImageClassification.from_pretrained("nprasad24/bean_classifier", from_tf=True)
|
43 |
image_processor = AutoImageProcessor.from_pretrained("nprasad24/bean_classifier")
|
@@ -87,7 +89,7 @@ def ragChain():
|
|
87 |
#APIKEY = "o7T3gVx9Vt8GSJbLyPV1974vF8LXVp01CWqOkWQuHgoHm07H"
|
88 |
#os.environ["FIREWORKS_API_KEY"] = APIKEY
|
89 |
|
90 |
-
llm =
|
91 |
|
92 |
prompt = ChatPromptTemplate.from_messages(
|
93 |
[
|
|
|
2 |
subprocess.run('pip install -r requirements.txt', shell = True)
|
3 |
|
4 |
import gradio as gr
|
5 |
+
import cv2
|
6 |
import os
|
7 |
from PIL import Image
|
8 |
import numpy as np
|
|
|
22 |
from rich.console import Console
|
23 |
from rich.markdown import Markdown
|
24 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
25 |
+
from langchain import HuggingFacePipeline
|
26 |
|
27 |
transformers.logging.set_verbosity_error()
|
28 |
|
|
|
36 |
|
37 |
output: Query for the LLM
|
38 |
"""
|
39 |
+
image = Image.open(image)
|
40 |
#image = cv2.imread(image)
|
41 |
#image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
42 |
+
#image = Image.fromarray(image)
|
43 |
|
44 |
model = AutoModelForImageClassification.from_pretrained("nprasad24/bean_classifier", from_tf=True)
|
45 |
image_processor = AutoImageProcessor.from_pretrained("nprasad24/bean_classifier")
|
|
|
89 |
#APIKEY = "o7T3gVx9Vt8GSJbLyPV1974vF8LXVp01CWqOkWQuHgoHm07H"
|
90 |
#os.environ["FIREWORKS_API_KEY"] = APIKEY
|
91 |
|
92 |
+
llm = HuggingFacePipeline.from_model_id(model_id=repo_id, task="text-generation")
|
93 |
|
94 |
prompt = ChatPromptTemplate.from_messages(
|
95 |
[
|