Spaces:
Paused
Paused
Upload multit2i.py
Browse files- multit2i.py +5 -6
multit2i.py
CHANGED
|
@@ -110,8 +110,7 @@ def get_t2i_model_info_dict(repo_id: str):
|
|
| 110 |
|
| 111 |
|
| 112 |
def rename_image(image_path: str | None, model_name: str, save_path: str | None = None):
|
| 113 |
-
from PIL import Image
|
| 114 |
-
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
| 115 |
from datetime import datetime, timezone, timedelta
|
| 116 |
if image_path is None: return None
|
| 117 |
dt_now = datetime.now(timezone(timedelta(hours=9)))
|
|
@@ -174,7 +173,7 @@ def load_from_model(model_name: str, hf_token: str | Literal[False] | None = Non
|
|
| 174 |
if "429" in str(e):
|
| 175 |
raise TooManyRequestsError() from e
|
| 176 |
except Exception as e:
|
| 177 |
-
raise Exception(e
|
| 178 |
return data
|
| 179 |
|
| 180 |
interface_info = {
|
|
@@ -385,7 +384,7 @@ def infer_body(client: InferenceClient | gr.Interface | object, prompt: str, neg
|
|
| 385 |
return str(Path(png_path).resolve())
|
| 386 |
except Exception as e:
|
| 387 |
print(e)
|
| 388 |
-
raise Exception(e
|
| 389 |
|
| 390 |
|
| 391 |
async def infer(model_name: str, prompt: str, neg_prompt: str | None = None,
|
|
@@ -410,12 +409,12 @@ async def infer(model_name: str, prompt: str, neg_prompt: str | None = None,
|
|
| 410 |
print(f"Task timed out: {model_name}")
|
| 411 |
if not task.done(): task.cancel()
|
| 412 |
result = None
|
| 413 |
-
raise Exception(f"Task timed out: {model_name}")
|
| 414 |
except Exception as e:
|
| 415 |
print(e)
|
| 416 |
if not task.done(): task.cancel()
|
| 417 |
result = None
|
| 418 |
-
raise Exception(e
|
| 419 |
if task.done() and result is not None:
|
| 420 |
with lock:
|
| 421 |
image = rename_image(result, model_name, save_path)
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
def rename_image(image_path: str | None, model_name: str, save_path: str | None = None):
|
| 113 |
+
from PIL import Image
|
|
|
|
| 114 |
from datetime import datetime, timezone, timedelta
|
| 115 |
if image_path is None: return None
|
| 116 |
dt_now = datetime.now(timezone(timedelta(hours=9)))
|
|
|
|
| 173 |
if "429" in str(e):
|
| 174 |
raise TooManyRequestsError() from e
|
| 175 |
except Exception as e:
|
| 176 |
+
raise Exception() from e
|
| 177 |
return data
|
| 178 |
|
| 179 |
interface_info = {
|
|
|
|
| 384 |
return str(Path(png_path).resolve())
|
| 385 |
except Exception as e:
|
| 386 |
print(e)
|
| 387 |
+
raise Exception() from e
|
| 388 |
|
| 389 |
|
| 390 |
async def infer(model_name: str, prompt: str, neg_prompt: str | None = None,
|
|
|
|
| 409 |
print(f"Task timed out: {model_name}")
|
| 410 |
if not task.done(): task.cancel()
|
| 411 |
result = None
|
| 412 |
+
raise Exception(f"Task timed out: {model_name}") from e
|
| 413 |
except Exception as e:
|
| 414 |
print(e)
|
| 415 |
if not task.done(): task.cancel()
|
| 416 |
result = None
|
| 417 |
+
raise Exception() from e
|
| 418 |
if task.done() and result is not None:
|
| 419 |
with lock:
|
| 420 |
image = rename_image(result, model_name, save_path)
|