Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,13 +37,18 @@ def run_texttoimage(text, file, font_size, width, height, bg_color, text_color,
|
|
| 37 |
"--align", align,
|
| 38 |
"--output", "output.png"
|
| 39 |
]
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
try:
|
| 42 |
result = subprocess.run(command, capture_output=True, text=True)
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
return "output.png"
|
| 45 |
else:
|
| 46 |
-
return f"Error: {result.stderr}"
|
| 47 |
except Exception as e:
|
| 48 |
return f"Execution failed: {e}"
|
| 49 |
|
|
@@ -74,4 +79,4 @@ demo = gr.Interface(
|
|
| 74 |
description="Ứng dụng chuyển văn bản thành ảnh sử dụng Texttoimage."
|
| 75 |
)
|
| 76 |
|
| 77 |
-
demo.launch()
|
|
|
|
| 37 |
"--align", align,
|
| 38 |
"--output", "output.png"
|
| 39 |
]
|
| 40 |
+
|
| 41 |
+
print("Running command:", " ".join(command)) # In lệnh chạy để debug
|
| 42 |
+
|
| 43 |
try:
|
| 44 |
result = subprocess.run(command, capture_output=True, text=True)
|
| 45 |
+
print("STDOUT:", result.stdout) # In output stdout
|
| 46 |
+
print("STDERR:", result.stderr) # In output stderr
|
| 47 |
+
|
| 48 |
+
if result.returncode == 0 and os.path.exists("output.png"):
|
| 49 |
return "output.png"
|
| 50 |
else:
|
| 51 |
+
return f"Error: {result.stderr or 'Output file not created!'}"
|
| 52 |
except Exception as e:
|
| 53 |
return f"Execution failed: {e}"
|
| 54 |
|
|
|
|
| 79 |
description="Ứng dụng chuyển văn bản thành ảnh sử dụng Texttoimage."
|
| 80 |
)
|
| 81 |
|
| 82 |
+
demo.launch()
|