Update app.py
Browse files
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 |
-
|
11 |
-
|
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 |
-
|
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
|