wishmi1234 commited on
Commit
c9e3b09
·
verified ·
1 Parent(s): 0c8ace7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -36,28 +36,31 @@ Your output must be: a single clean answer string only.
36
 
37
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
38
 
 
 
39
  class ImageCaptioningTool(Tool):
40
  name = "image_captioner"
41
- description = "Generate a caption for an image."
 
42
  inputs = {
43
  "image": {
44
- "type": "dict",
45
- "description": "A dictionary containing image data in PIL format."
46
  },
47
  "question": {
48
- "type": "str",
49
- "description": "A question or prompt about the image."
50
  }
51
  }
52
- output_type = "text"
 
53
 
54
  def run(self, inputs: dict) -> str:
55
- image = inputs.get("image")
56
- if not image:
57
- return "No image provided."
58
- # Here you can process the image using your model
59
- return "This is a placeholder caption for the uploaded image."
60
-
61
  # class ImageCaptioningTool(Tool):
62
  # name = "image_captioner"
63
  # description = "Generate a caption for an image."
 
36
 
37
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
38
 
39
+ from smolagents.schema import Tool
40
+
41
  class ImageCaptioningTool(Tool):
42
  name = "image_captioner"
43
+ description = "Generate a caption for an image using a prompt or question."
44
+
45
  inputs = {
46
  "image": {
47
+ "type": "image",
48
+ "description": "An image file input."
49
  },
50
  "question": {
51
+ "type": "string",
52
+ "description": "A prompt or question about the image."
53
  }
54
  }
55
+
56
+ output_type = "string"
57
 
58
  def run(self, inputs: dict) -> str:
59
+ image = inputs["image"]
60
+ question = inputs["question"]
61
+ # Dummy logic – replace with actual model
62
+ return f"Captioning image for: {question}"
63
+
 
64
  # class ImageCaptioningTool(Tool):
65
  # name = "image_captioner"
66
  # description = "Generate a caption for an image."