KingNish commited on
Commit
543cd64
1 Parent(s): 99482fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -25
app.py CHANGED
@@ -119,28 +119,28 @@ def king(type = "Image Editing",
119
  return seed, output_image
120
 
121
  def response(instruction, input_image=None):
122
- client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
123
-
124
- generate_kwargs = dict(
125
- max_new_tokens=5,
126
- )
127
-
128
- 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]"
129
-
130
- formatted_prompt = system + instruction + "[TASK]"
131
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
132
- output = ""
133
- for response in stream:
134
- if not response.token.text == "</s>":
135
- output += response.token.text
136
-
137
  if input_image is None:
138
  output="Image Generation"
139
-
140
- if "editing" in output:
141
- output = "Image Editing"
142
  else:
143
- output = "Image Generation"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  return output
145
 
146
  css = '''
@@ -152,31 +152,36 @@ footer {
152
  '''
153
 
154
  def get_example():
155
- case = [
156
  [
157
  "Image Generation",
158
- "A Super Car",
159
  None,
 
 
160
  ],
161
  [
162
  "Image Editing",
163
- "make it red",
164
  "./supercar.png",
 
 
165
  ],
166
  [
167
  "Image Editing",
168
- "add some snow",
169
  "./red_car.png",
 
 
170
  ],
171
  [
172
  "Image Generation",
173
- "Ironman flying in front of Ststue of liberty",
174
  None,
 
 
175
  ],
176
  [
177
  "Image Generation",
 
178
  "Beautiful Eiffel Tower at Night",
179
- None,
180
  ],
181
  ]
182
  return case
 
119
  return seed, output_image
120
 
121
  def response(instruction, input_image=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  if input_image is None:
123
  output="Image Generation"
 
 
 
124
  else:
125
+ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
126
+
127
+ generate_kwargs = dict(
128
+ max_new_tokens=5,
129
+ )
130
+
131
+ 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]"
132
+
133
+ formatted_prompt = system + instruction + "[TASK]"
134
+ stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
135
+ output = ""
136
+ for response in stream:
137
+ if not response.token.text == "</s>":
138
+ output += response.token.text
139
+ if "editing" in output:
140
+ output = "Image Editing"
141
+ else:
142
+ output = "Image Generation"
143
+ yield output
144
  return output
145
 
146
  css = '''
 
152
  '''
153
 
154
  def get_example():
155
+ case = [
156
  [
157
  "Image Generation",
 
158
  None,
159
+ "A Super Car",
160
+
161
  ],
162
  [
163
  "Image Editing",
 
164
  "./supercar.png",
165
+ "make it red",
166
+
167
  ],
168
  [
169
  "Image Editing",
 
170
  "./red_car.png",
171
+ "add some snow",
172
+
173
  ],
174
  [
175
  "Image Generation",
 
176
  None,
177
+ "Kids going o school, Anime style",
178
+
179
  ],
180
  [
181
  "Image Generation",
182
+ None,
183
  "Beautiful Eiffel Tower at Night",
184
+
185
  ],
186
  ]
187
  return case