Commit
•
ded3b8b
1
Parent(s):
dd195c1
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import argparse
|
|
5 |
import shutil
|
6 |
from train_dreambooth import run_training
|
7 |
from PIL import Image
|
|
|
8 |
|
9 |
css = '''
|
10 |
.instruction{position: absolute; top: 0;right: 0;margin-top: 0px !important}
|
@@ -64,7 +65,7 @@ def train(*inputs):
|
|
64 |
image = file.crop((left, top, right, bottom))
|
65 |
image = image.resize((512, 512))
|
66 |
extension = file_temp.name.split(".")[1]
|
67 |
-
image.convert('RGB')
|
68 |
image.save(f'instance_images/{prompt}_({j+1}).jpg', format="JPEG", quality = 100)
|
69 |
file_counter += 1
|
70 |
|
@@ -159,6 +160,7 @@ def train(*inputs):
|
|
159 |
shutil.rmtree('instance_images')
|
160 |
shutil.make_archive("output_model", 'zip', "output_model")
|
161 |
shutil.rmtree("output_model")
|
|
|
162 |
return [gr.update(visible=True, value="output_model.zip"), gr.update(visible=True), gr.update(visible=True)]
|
163 |
|
164 |
with gr.Blocks(css=css) as demo:
|
@@ -251,6 +253,6 @@ with gr.Blocks(css=css) as demo:
|
|
251 |
gr.Markdown("Push to Hugging Face Hub")
|
252 |
model_repo_tag = gr.Textbox(label="Model name or URL", placeholder="username/model_name")
|
253 |
push_button = gr.Button("Push to the Hub")
|
254 |
-
result = gr.File(label="Download the uploaded models (zip file are diffusers weights, *.ckpt are CompVis/AUTOMATIC1111 weights)", visible=
|
255 |
train_btn.click(fn=train, inputs=is_visible+concept_collection+file_collection+[type_of_thing]+[steps]+[perc_txt_encoder]+[swap_auto_calculated], outputs=[result, try_your_model, push_to_hub])
|
256 |
demo.launch()
|
|
|
5 |
import shutil
|
6 |
from train_dreambooth import run_training
|
7 |
from PIL import Image
|
8 |
+
import torch
|
9 |
|
10 |
css = '''
|
11 |
.instruction{position: absolute; top: 0;right: 0;margin-top: 0px !important}
|
|
|
65 |
image = file.crop((left, top, right, bottom))
|
66 |
image = image.resize((512, 512))
|
67 |
extension = file_temp.name.split(".")[1]
|
68 |
+
image = image.convert('RGB')
|
69 |
image.save(f'instance_images/{prompt}_({j+1}).jpg', format="JPEG", quality = 100)
|
70 |
file_counter += 1
|
71 |
|
|
|
160 |
shutil.rmtree('instance_images')
|
161 |
shutil.make_archive("output_model", 'zip', "output_model")
|
162 |
shutil.rmtree("output_model")
|
163 |
+
torch.cuda.empty_cache()
|
164 |
return [gr.update(visible=True, value="output_model.zip"), gr.update(visible=True), gr.update(visible=True)]
|
165 |
|
166 |
with gr.Blocks(css=css) as demo:
|
|
|
253 |
gr.Markdown("Push to Hugging Face Hub")
|
254 |
model_repo_tag = gr.Textbox(label="Model name or URL", placeholder="username/model_name")
|
255 |
push_button = gr.Button("Push to the Hub")
|
256 |
+
result = gr.File(label="Download the uploaded models (zip file are diffusers weights, *.ckpt are CompVis/AUTOMATIC1111 weights)", visible=True)
|
257 |
train_btn.click(fn=train, inputs=is_visible+concept_collection+file_collection+[type_of_thing]+[steps]+[perc_txt_encoder]+[swap_auto_calculated], outputs=[result, try_your_model, push_to_hub])
|
258 |
demo.launch()
|