AMfeta99 commited on
Commit
4abd9be
·
verified ·
1 Parent(s): 97dbe65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -7,16 +7,17 @@ from gradio_client import Client
7
  class TextToImageTool(Tool):
8
  name = "text_to_image"
9
  description = "Generate an image from a text prompt using m-ric/text-to-image."
10
- inputs = ["prompt"] # Required by smolagents
11
- outputs = ["image"] # Not used directly but required
12
-
 
 
13
  def __init__(self):
14
  super().__init__()
15
  self.client = Client("m-ric/text-to-image")
16
 
17
  def run(self, prompt: str):
18
- image = self.client.predict(prompt, api_name="/predict")
19
- return image # PIL.Image
20
 
21
 
22
  #%% Utility functions
 
7
  class TextToImageTool(Tool):
8
  name = "text_to_image"
9
  description = "Generate an image from a text prompt using m-ric/text-to-image."
10
+
11
+ # `inputs` is a dictionary: argument_name -> type
12
+ inputs = {"prompt": str}
13
+ outputs = {"image": "image"} # Optional, type can be a string or class
14
+
15
  def __init__(self):
16
  super().__init__()
17
  self.client = Client("m-ric/text-to-image")
18
 
19
  def run(self, prompt: str):
20
+ return self.client.predict(prompt, api_name="/predict") # Returns PIL.Image
 
21
 
22
 
23
  #%% Utility functions