Spaces:
Sleeping
Sleeping
layerdiffusion
commited on
Commit
·
4d65fef
1
Parent(s):
c033d98
app.py
CHANGED
|
@@ -120,9 +120,11 @@ def resize_without_crop(image, target_width, target_height):
|
|
| 120 |
return np.array(resized_image)
|
| 121 |
|
| 122 |
|
| 123 |
-
@spaces.GPU
|
| 124 |
@torch.inference_mode()
|
| 125 |
def chat_fn(message: str, history: list, seed:int, temperature: float, top_p: float, max_new_tokens: int) -> str:
|
|
|
|
|
|
|
| 126 |
np.random.seed(int(seed))
|
| 127 |
torch.manual_seed(int(seed))
|
| 128 |
|
|
@@ -160,6 +162,7 @@ def chat_fn(message: str, history: list, seed:int, temperature: float, top_p: fl
|
|
| 160 |
# print(outputs)
|
| 161 |
yield "".join(outputs)
|
| 162 |
|
|
|
|
| 163 |
return
|
| 164 |
|
| 165 |
|
|
@@ -175,6 +178,7 @@ def post_chat(history):
|
|
| 175 |
except Exception as e:
|
| 176 |
print('Last assistant response is not valid canvas:', e)
|
| 177 |
|
|
|
|
| 178 |
return canvas_outputs, gr.update(visible=canvas_outputs is not None)
|
| 179 |
|
| 180 |
|
|
|
|
| 120 |
return np.array(resized_image)
|
| 121 |
|
| 122 |
|
| 123 |
+
@spaces.GPU(duration=120)
|
| 124 |
@torch.inference_mode()
|
| 125 |
def chat_fn(message: str, history: list, seed:int, temperature: float, top_p: float, max_new_tokens: int) -> str:
|
| 126 |
+
print('Chat begin:', message)
|
| 127 |
+
|
| 128 |
np.random.seed(int(seed))
|
| 129 |
torch.manual_seed(int(seed))
|
| 130 |
|
|
|
|
| 162 |
# print(outputs)
|
| 163 |
yield "".join(outputs)
|
| 164 |
|
| 165 |
+
print('Chat end:', message)
|
| 166 |
return
|
| 167 |
|
| 168 |
|
|
|
|
| 178 |
except Exception as e:
|
| 179 |
print('Last assistant response is not valid canvas:', e)
|
| 180 |
|
| 181 |
+
print('Canvas detection', canvas_outputs is not None)
|
| 182 |
return canvas_outputs, gr.update(visible=canvas_outputs is not None)
|
| 183 |
|
| 184 |
|