Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -315,6 +315,8 @@ def read_and_split_hf(display_name):
|
|
| 315 |
|
| 316 |
|
| 317 |
def generate_image(prompt: str):
|
|
|
|
|
|
|
| 318 |
|
| 319 |
TMP_DIR = "tmp_images"
|
| 320 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
@@ -325,8 +327,8 @@ def generate_image(prompt: str):
|
|
| 325 |
|
| 326 |
# Chạy Playwright headless
|
| 327 |
with sync_playwright() as p:
|
| 328 |
-
|
| 329 |
-
browser = p.chromium.launch(headless=True)
|
| 330 |
page = browser.new_page()
|
| 331 |
|
| 332 |
page.goto("https://imagenfx.art/image", timeout=60000)
|
|
@@ -348,6 +350,7 @@ def generate_image(prompt: str):
|
|
| 348 |
|
| 349 |
return filepath, filepath # Trả về file cho show + download
|
| 350 |
|
|
|
|
| 351 |
|
| 352 |
|
| 353 |
# ======================
|
|
|
|
| 315 |
|
| 316 |
|
| 317 |
def generate_image(prompt: str):
|
| 318 |
+
import os, re, base64
|
| 319 |
+
from playwright.sync_api import sync_playwright
|
| 320 |
|
| 321 |
TMP_DIR = "tmp_images"
|
| 322 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
|
|
| 327 |
|
| 328 |
# Chạy Playwright headless
|
| 329 |
with sync_playwright() as p:
|
| 330 |
+
# Bắt Playwright dùng Chromium đã cài
|
| 331 |
+
browser = p.chromium.launch(headless=True, executable_path=p.chromium.executable_path())
|
| 332 |
page = browser.new_page()
|
| 333 |
|
| 334 |
page.goto("https://imagenfx.art/image", timeout=60000)
|
|
|
|
| 350 |
|
| 351 |
return filepath, filepath # Trả về file cho show + download
|
| 352 |
|
| 353 |
+
|
| 354 |
|
| 355 |
|
| 356 |
# ======================
|