Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,13 @@ import os
|
|
4 |
from dotenv import load_dotenv
|
5 |
import warnings
|
6 |
|
7 |
-
# Suppress
|
8 |
-
warnings.filterwarnings('ignore', category=UserWarning
|
9 |
|
10 |
# Load environment variables
|
11 |
load_dotenv()
|
12 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
13 |
|
14 |
-
# Check CUDA availability and set device
|
15 |
-
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
-
|
17 |
def generate_diagram(prompt, width=1024, height=1024):
|
18 |
"""Generate a diagram using FLUX AI"""
|
19 |
try:
|
@@ -35,6 +32,7 @@ def generate_diagram(prompt, width=1024, height=1024):
|
|
35 |
raise gr.Error(f"Error generating diagram: {str(e)}")
|
36 |
|
37 |
|
|
|
38 |
# Enhanced examples with more detailed prompts and specific styling
|
39 |
EXAMPLES = [
|
40 |
{
|
@@ -238,8 +236,6 @@ GRADIO_EXAMPLES = [
|
|
238 |
for example in EXAMPLES
|
239 |
]
|
240 |
|
241 |
-
# Create Gradio interface
|
242 |
-
# Gradio interface ๋ถ๋ถ ์์
|
243 |
demo = gr.Interface(
|
244 |
fn=generate_diagram,
|
245 |
inputs=[
|
@@ -283,16 +279,15 @@ demo = gr.Interface(
|
|
283 |
โโโ DETAIL 2 [Icon]
|
284 |
```
|
285 |
""",
|
286 |
-
examples=GRADIO_EXAMPLES,
|
287 |
cache_examples=True,
|
288 |
-
theme=gr.themes.Soft()
|
289 |
-
allow_flagging="never" # ๋ถํ์ํ ํ๋๊น
๊ธฐ๋ฅ ์ ๊ฑฐ
|
290 |
)
|
291 |
|
292 |
-
# Launch
|
293 |
if __name__ == "__main__":
|
294 |
try:
|
295 |
-
demo.queue(max_size=10)
|
296 |
demo.launch(
|
297 |
server_name="0.0.0.0",
|
298 |
server_port=7860,
|
|
|
4 |
from dotenv import load_dotenv
|
5 |
import warnings
|
6 |
|
7 |
+
# Suppress warnings
|
8 |
+
warnings.filterwarnings('ignore', category=UserWarning)
|
9 |
|
10 |
# Load environment variables
|
11 |
load_dotenv()
|
12 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
13 |
|
|
|
|
|
|
|
14 |
def generate_diagram(prompt, width=1024, height=1024):
|
15 |
"""Generate a diagram using FLUX AI"""
|
16 |
try:
|
|
|
32 |
raise gr.Error(f"Error generating diagram: {str(e)}")
|
33 |
|
34 |
|
35 |
+
|
36 |
# Enhanced examples with more detailed prompts and specific styling
|
37 |
EXAMPLES = [
|
38 |
{
|
|
|
236 |
for example in EXAMPLES
|
237 |
]
|
238 |
|
|
|
|
|
239 |
demo = gr.Interface(
|
240 |
fn=generate_diagram,
|
241 |
inputs=[
|
|
|
279 |
โโโ DETAIL 2 [Icon]
|
280 |
```
|
281 |
""",
|
282 |
+
examples=GRADIO_EXAMPLES,
|
283 |
cache_examples=True,
|
284 |
+
theme=gr.themes.Soft()
|
|
|
285 |
)
|
286 |
|
287 |
+
# Launch app
|
288 |
if __name__ == "__main__":
|
289 |
try:
|
290 |
+
demo.queue(max_size=10)
|
291 |
demo.launch(
|
292 |
server_name="0.0.0.0",
|
293 |
server_port=7860,
|