Spaces:
Running
Running
Update flux_train_ui.py
Browse files- flux_train_ui.py +1 -56
flux_train_ui.py
CHANGED
@@ -3,11 +3,6 @@ from huggingface_hub import whoami
|
|
3 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
4 |
import sys
|
5 |
import spaces
|
6 |
-
import gradio as gr
|
7 |
-
from fastapi import FastAPI, Request
|
8 |
-
import uvicorn
|
9 |
-
from fastapi import Request
|
10 |
-
|
11 |
# Add the current working directory to the Python path
|
12 |
sys.path.insert(0, os.getcwd())
|
13 |
|
@@ -26,26 +21,6 @@ sys.path.insert(0, "ai-toolkit")
|
|
26 |
from toolkit.job import get_job
|
27 |
|
28 |
MAX_IMAGES = 150
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
def load_captioning(uploaded_files, concept_sentence):
|
51 |
uploaded_images = [file for file in uploaded_files if not file.endswith('.txt')]
|
@@ -452,35 +427,5 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
452 |
|
453 |
do_captioning.click(fn=run_captioning, inputs=[images, concept_sentence] + caption_list, outputs=caption_list)
|
454 |
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
def train_model_ui(data: str):
|
462 |
-
print(f"🚀 Triggered with input: {data}")
|
463 |
-
return f"✅ Received: {data}"
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
# ⬇️ DO NOT remove this since you're keeping the manual launch
|
468 |
-
# Main FastAPI app
|
469 |
-
app = FastAPI()
|
470 |
-
|
471 |
-
# Mount the Gradio app at root ("/")
|
472 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
473 |
-
|
474 |
-
# Custom POST endpoint
|
475 |
-
@app.post("/trigger")
|
476 |
-
async def trigger(request: Request):
|
477 |
-
body = await request.json()
|
478 |
-
input_data = body.get("input", "")
|
479 |
-
result = train_model_ui(input_data)
|
480 |
-
return {"result": result}
|
481 |
-
|
482 |
-
# Run everything
|
483 |
if __name__ == "__main__":
|
484 |
-
|
485 |
-
|
486 |
-
|
|
|
3 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
4 |
import sys
|
5 |
import spaces
|
|
|
|
|
|
|
|
|
|
|
6 |
# Add the current working directory to the Python path
|
7 |
sys.path.insert(0, os.getcwd())
|
8 |
|
|
|
21 |
from toolkit.job import get_job
|
22 |
|
23 |
MAX_IMAGES = 150
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
def load_captioning(uploaded_files, concept_sentence):
|
26 |
uploaded_images = [file for file in uploaded_files if not file.endswith('.txt')]
|
|
|
427 |
|
428 |
do_captioning.click(fn=run_captioning, inputs=[images, concept_sentence] + caption_list, outputs=caption_list)
|
429 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
if __name__ == "__main__":
|
431 |
+
demo.launch(share=True, show_error=True)
|
|
|
|