Update app.py
Browse files
app.py
CHANGED
|
@@ -32,8 +32,6 @@ def get_negative_prompt():
|
|
| 32 |
negative_prompt = st.text_input('Enter your negative prompt here:', placeholder="low quality, out of frame, watermark.. etc.")
|
| 33 |
return negative_prompt
|
| 34 |
|
| 35 |
-
import os
|
| 36 |
-
|
| 37 |
def get_user_input():
|
| 38 |
st.subheader("Upload an image file, Press Clean Background Button.")
|
| 39 |
uploaded_file = st.file_uploader("Upload a JPG image file", type=["jpg", "jpeg"])
|
|
@@ -108,14 +106,15 @@ def load_images():
|
|
| 108 |
if button_1:
|
| 109 |
button_1_clicked = True
|
| 110 |
# Move items from data/custom_dataset/ to data/processed
|
| 111 |
-
log( copy= True)
|
|
|
|
| 112 |
if uploaded_file is not None:
|
| 113 |
uploaded_file.save(user_file_path)
|
| 114 |
run_subprocess()
|
| 115 |
-
clean_files("data/custom_dataset/")
|
| 116 |
st.success("Background cleaned.")
|
| 117 |
log(copy = True)
|
| 118 |
|
|
|
|
| 119 |
|
| 120 |
st.subheader("Text your prompt and choose parameters, then press Run Model button")
|
| 121 |
|
|
@@ -134,9 +133,8 @@ num_images_per_prompt = st.slider('Image Count to be Produced:', min_value=1, ma
|
|
| 134 |
# use seed with torch generator
|
| 135 |
#torch.manual_seed(0)
|
| 136 |
# seed
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
generator = [torch.Generator(device="cuda").manual_seed(seed) for i in range(num_images_per_prompt)]
|
| 140 |
|
| 141 |
#generator = torch.Generator(device="cuda").manual_seed(0)
|
| 142 |
run_model_button = st.button("Run Model")
|
|
@@ -181,7 +179,6 @@ def show_output(x5):
|
|
| 181 |
|
| 182 |
# Check if the button is clicked and all inputs are provided
|
| 183 |
if run_model_button == True and input_prompt is not None :
|
| 184 |
-
dif_image , inverted_image = load_images()
|
| 185 |
st.write("Running the model...")
|
| 186 |
dif_image , inverted_image = load_images()
|
| 187 |
output_width, output_height = image_resize(dif_image)
|
|
@@ -195,7 +192,7 @@ if run_model_button == True and input_prompt is not None :
|
|
| 195 |
#output_height = 128
|
| 196 |
#output_width = 128
|
| 197 |
|
| 198 |
-
x5 = pipe(image=dif_image, mask_image=inverted_image, num_inference_steps=num_inference_steps,generator= generator
|
| 199 |
num_images_per_prompt=num_images_per_prompt, prompt=prompt, negative_prompt=input_negative_prompt,
|
| 200 |
height=output_height, width=output_width).images
|
| 201 |
|
|
|
|
| 32 |
negative_prompt = st.text_input('Enter your negative prompt here:', placeholder="low quality, out of frame, watermark.. etc.")
|
| 33 |
return negative_prompt
|
| 34 |
|
|
|
|
|
|
|
| 35 |
def get_user_input():
|
| 36 |
st.subheader("Upload an image file, Press Clean Background Button.")
|
| 37 |
uploaded_file = st.file_uploader("Upload a JPG image file", type=["jpg", "jpeg"])
|
|
|
|
| 106 |
if button_1:
|
| 107 |
button_1_clicked = True
|
| 108 |
# Move items from data/custom_dataset/ to data/processed
|
| 109 |
+
log( copy= True)
|
| 110 |
+
clean_files("data/custom_dataset/")
|
| 111 |
if uploaded_file is not None:
|
| 112 |
uploaded_file.save(user_file_path)
|
| 113 |
run_subprocess()
|
|
|
|
| 114 |
st.success("Background cleaned.")
|
| 115 |
log(copy = True)
|
| 116 |
|
| 117 |
+
|
| 118 |
|
| 119 |
st.subheader("Text your prompt and choose parameters, then press Run Model button")
|
| 120 |
|
|
|
|
| 133 |
# use seed with torch generator
|
| 134 |
#torch.manual_seed(0)
|
| 135 |
# seed
|
| 136 |
+
#seed = st.slider('Seed:', min_value=0, max_value=100, value=1)
|
| 137 |
+
#generator = [torch.Generator(device="cuda").manual_seed(seed) for i in range(num_images_per_prompt)]
|
|
|
|
| 138 |
|
| 139 |
#generator = torch.Generator(device="cuda").manual_seed(0)
|
| 140 |
run_model_button = st.button("Run Model")
|
|
|
|
| 179 |
|
| 180 |
# Check if the button is clicked and all inputs are provided
|
| 181 |
if run_model_button == True and input_prompt is not None :
|
|
|
|
| 182 |
st.write("Running the model...")
|
| 183 |
dif_image , inverted_image = load_images()
|
| 184 |
output_width, output_height = image_resize(dif_image)
|
|
|
|
| 192 |
#output_height = 128
|
| 193 |
#output_width = 128
|
| 194 |
|
| 195 |
+
x5 = pipe(image=dif_image, mask_image=inverted_image, num_inference_steps=num_inference_steps, # , generator= generator
|
| 196 |
num_images_per_prompt=num_images_per_prompt, prompt=prompt, negative_prompt=input_negative_prompt,
|
| 197 |
height=output_height, width=output_width).images
|
| 198 |
|