Spaces:
Runtime error
Runtime error
Commit
•
a650e86
1
Parent(s):
84e6df0
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,9 @@ from typing import Union
|
|
4 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
5 |
|
6 |
if is_spaces:
|
7 |
-
import spaces
|
8 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
|
|
|
|
9 |
|
10 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
11 |
import sys
|
@@ -67,7 +68,7 @@ def load_captioning(uploaded_images, concept_sentence):
|
|
67 |
|
68 |
# Update for the sample caption area
|
69 |
updates.append(gr.update(visible=True))
|
70 |
-
updates.append(gr.update(placeholder=f'A
|
71 |
updates.append(gr.update(placeholder=f"A mountainous landscape in the style of {concept_sentence}"))
|
72 |
updates.append(gr.update(placeholder=f"A {concept_sentence} in a mall"))
|
73 |
return updates
|
@@ -221,6 +222,8 @@ theme = gr.themes.Monochrome(
|
|
221 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "ui-sans-serif", "system-ui", "sans-serif"],
|
222 |
)
|
223 |
css = """
|
|
|
|
|
224 |
#component-1{text-align:center}
|
225 |
.main_ui_logged_out{opacity: 0.3; pointer-events: none}
|
226 |
.tabitem{border: 0px}
|
@@ -308,7 +311,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
308 |
lr = gr.Number(label="Learning Rate", value=4e-4, minimum=1e-6, maximum=1e-3, step=1e-6)
|
309 |
rank = gr.Number(label="LoRA Rank", value=16, minimum=4, maximum=128, step=4)
|
310 |
|
311 |
-
with gr.Accordion("Sample prompts", visible=False) as sample:
|
312 |
gr.Markdown(
|
313 |
"Include sample prompts to test out your trained model. Don't forget to include your trigger word/sentence (optional)"
|
314 |
)
|
@@ -323,12 +326,18 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
323 |
start = gr.Button("Start training")
|
324 |
progress_area = gr.Markdown("")
|
325 |
|
326 |
-
with gr.Tab("Train
|
327 |
gr.Markdown(
|
328 |
-
f"""To use FLUX LoRA Ease locally with this UI, you can clone this repository (yes, HF Spaces are git repos!)
|
329 |
```bash
|
330 |
git clone https://huggingface.co/spaces/flux-train/flux-lora-trainer
|
331 |
cd flux-lora-trainer
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
pip install requirements_local.txt
|
333 |
```
|
334 |
|
@@ -337,10 +346,6 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
337 |
git clone https://github.com/ostris/ai-toolkit.git
|
338 |
cd ai-toolkit
|
339 |
git submodule update --init --recursive
|
340 |
-
python3 -m venv venv
|
341 |
-
source venv/bin/activate
|
342 |
-
# .\venv\Scripts\activate on windows
|
343 |
-
# install torch first
|
344 |
pip3 install torch
|
345 |
pip3 install -r requirements.txt
|
346 |
cd ..
|
@@ -351,10 +356,11 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
351 |
huggingface-cli login
|
352 |
```
|
353 |
|
354 |
-
Now you can run FLUX LoRA Ease locally by doing a simple
|
355 |
```py
|
356 |
python app.py
|
357 |
```
|
|
|
358 |
If you prefer command line, you can run Ostris' [AI Toolkit](https://github.com/ostris/ai-toolkit) yourself directly.
|
359 |
"""
|
360 |
)
|
|
|
4 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
5 |
|
6 |
if is_spaces:
|
|
|
7 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
8 |
+
import spaces
|
9 |
+
|
10 |
|
11 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
12 |
import sys
|
|
|
68 |
|
69 |
# Update for the sample caption area
|
70 |
updates.append(gr.update(visible=True))
|
71 |
+
updates.append(gr.update(placeholder=f'A portrait of person in a bustling cafe {concept_sentence}', value=f'A person in a bustling cafe {concept_sentence}'))
|
72 |
updates.append(gr.update(placeholder=f"A mountainous landscape in the style of {concept_sentence}"))
|
73 |
updates.append(gr.update(placeholder=f"A {concept_sentence} in a mall"))
|
74 |
return updates
|
|
|
222 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "ui-sans-serif", "system-ui", "sans-serif"],
|
223 |
)
|
224 |
css = """
|
225 |
+
h1{font-size: 2em}
|
226 |
+
h3{margin-top: 0}
|
227 |
#component-1{text-align:center}
|
228 |
.main_ui_logged_out{opacity: 0.3; pointer-events: none}
|
229 |
.tabitem{border: 0px}
|
|
|
311 |
lr = gr.Number(label="Learning Rate", value=4e-4, minimum=1e-6, maximum=1e-3, step=1e-6)
|
312 |
rank = gr.Number(label="LoRA Rank", value=16, minimum=4, maximum=128, step=4)
|
313 |
|
314 |
+
with gr.Accordion("Sample prompts (optional)", visible=False) as sample:
|
315 |
gr.Markdown(
|
316 |
"Include sample prompts to test out your trained model. Don't forget to include your trigger word/sentence (optional)"
|
317 |
)
|
|
|
326 |
start = gr.Button("Start training")
|
327 |
progress_area = gr.Markdown("")
|
328 |
|
329 |
+
with gr.Tab("Train on your device" if is_spaces else "Instructions"):
|
330 |
gr.Markdown(
|
331 |
+
f"""To use FLUX LoRA Ease locally with this UI, you can clone this repository (yes, HF Spaces are git repos!). You'll need ~23GB of VRAM
|
332 |
```bash
|
333 |
git clone https://huggingface.co/spaces/flux-train/flux-lora-trainer
|
334 |
cd flux-lora-trainer
|
335 |
+
## Optional, start a venv environment ##
|
336 |
+
python3 -m venv venv
|
337 |
+
source venv/bin/activate
|
338 |
+
# .\venv\Scripts\activate on windows
|
339 |
+
# install torch first
|
340 |
+
## End of optional ##
|
341 |
pip install requirements_local.txt
|
342 |
```
|
343 |
|
|
|
346 |
git clone https://github.com/ostris/ai-toolkit.git
|
347 |
cd ai-toolkit
|
348 |
git submodule update --init --recursive
|
|
|
|
|
|
|
|
|
349 |
pip3 install torch
|
350 |
pip3 install -r requirements.txt
|
351 |
cd ..
|
|
|
356 |
huggingface-cli login
|
357 |
```
|
358 |
|
359 |
+
Now you can run FLUX LoRA Ease locally with a UI by doing a simple
|
360 |
```py
|
361 |
python app.py
|
362 |
```
|
363 |
+
|
364 |
If you prefer command line, you can run Ostris' [AI Toolkit](https://github.com/ostris/ai-toolkit) yourself directly.
|
365 |
"""
|
366 |
)
|