vonliechti commited on
Commit
58282f8
·
verified ·
1 Parent(s): 7508807

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. .gitignore +3 -0
  2. app.py +10 -9
.gitignore CHANGED
@@ -1,6 +1,9 @@
1
  # MacOS
2
  .DS_Store
3
 
 
 
 
4
  # Data
5
  chroma_db/
6
  data/
 
1
  # MacOS
2
  .DS_Store
3
 
4
+ # Optimization
5
+ *.pyi
6
+
7
  # Data
8
  chroma_db/
9
  data/
app.py CHANGED
@@ -13,6 +13,7 @@ from transformers.agents import (
13
  VisitWebpageTool,
14
  )
15
  from tools.text_to_image import TextToImageTool
 
16
  from transformers import load_tool
17
  from prompts import (
18
  DEFAULT_SQUAD_REACT_CODE_SYSTEM_PROMPT,
@@ -39,19 +40,19 @@ model_name = (
39
  else "http://localhost:1234/v1"
40
  )
41
 
42
- image_qa_tool = ImageQuestionAnsweringTool()
43
- image_qa_tool.inputs = {
44
- "image": {
45
- "type": "image",
46
- "description": "The image containing the information. It must be a PIL Image.",
47
- },
48
- "question": {"type": "string", "description": "The question in English"},
49
- }
50
 
51
  ADDITIONAL_TOOLS = [
52
  DuckDuckGoSearchTool(),
53
  VisitWebpageTool(),
54
- ImageQuestionAnsweringTool(),
55
  load_tool("speech_to_text"),
56
  load_tool("text_to_speech"),
57
  load_tool("translation"),
 
13
  VisitWebpageTool,
14
  )
15
  from tools.text_to_image import TextToImageTool
16
+ from PIL import Image
17
  from transformers import load_tool
18
  from prompts import (
19
  DEFAULT_SQUAD_REACT_CODE_SYSTEM_PROMPT,
 
40
  else "http://localhost:1234/v1"
41
  )
42
 
43
+ class FixImageQuestionAnsweringTool(ImageQuestionAnsweringTool):
44
+ def __init__(self, *args, **kwargs):
45
+ super().__init__(*args, **kwargs)
46
+
47
+ def encode(self, image: "Image | str", question: str):
48
+ if isinstance(image, str):
49
+ image = Image.open(image)
50
+ return super().encode(image, question)
51
 
52
  ADDITIONAL_TOOLS = [
53
  DuckDuckGoSearchTool(),
54
  VisitWebpageTool(),
55
+ FixImageQuestionAnsweringTool(),
56
  load_tool("speech_to_text"),
57
  load_tool("text_to_speech"),
58
  load_tool("translation"),