Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -96,30 +96,19 @@ def king(type ,
|
|
96 |
return seed, image
|
97 |
|
98 |
# Prompt classifier
|
99 |
-
def response(instruction, input_image=None):
|
100 |
if input_image is None:
|
101 |
output="Image Generation"
|
102 |
-
yield output
|
103 |
else:
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
system="[SYSTEM] You will be provided with text, and your task is to classify task is image generation or image editing answer with only task do not say anything else and stop as soon as possible. [TEXT]"
|
111 |
-
|
112 |
-
formatted_prompt = system + instruction + "[TASK]"
|
113 |
-
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
114 |
-
output = ""
|
115 |
-
for response in stream:
|
116 |
-
if not response.token.text == "</s>":
|
117 |
-
output += response.token.text
|
118 |
-
if "editing" in output:
|
119 |
output = "Image Editing"
|
120 |
else:
|
121 |
output = "Image Generation"
|
122 |
-
yield output
|
123 |
return output
|
124 |
|
125 |
css = '''
|
|
|
96 |
return seed, image
|
97 |
|
98 |
# Prompt classifier
|
99 |
+
def response(instruction, input_image=None ):
|
100 |
if input_image is None:
|
101 |
output="Image Generation"
|
|
|
102 |
else:
|
103 |
+
text = instruction
|
104 |
+
labels = ["Image Editing", "Image Generation"]
|
105 |
+
classification = client.zero_shot_classification(text, labels, multi_label=True)
|
106 |
+
output = classification[0]
|
107 |
+
output = str(output)
|
108 |
+
if "Editing" in output:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
output = "Image Editing"
|
110 |
else:
|
111 |
output = "Image Generation"
|
|
|
112 |
return output
|
113 |
|
114 |
css = '''
|