Update app.py
Browse files
app.py
CHANGED
@@ -10,16 +10,14 @@ device = "cpu"
|
|
10 |
model_repo_id = "stabilityai/sdxl-turbo" # Continuando com o modelo especificado
|
11 |
|
12 |
# Carregar o pipeline configurado para CPU
|
13 |
-
pipe = DiffusionPipeline.from_pretrained(model_repo_id
|
14 |
pipe = pipe.to(device)
|
15 |
|
16 |
-
# Atualize as configurações do pipeline diretamente
|
17 |
-
pipe.unet.config.sample_size = (808, 512) # Ajuste de altura e largura divisíveis por 8
|
18 |
-
|
19 |
# Carregando o dataset do Hugging Face
|
20 |
dataset = load_dataset("LEIDIA/Data_Womleimg")
|
21 |
|
22 |
|
|
|
23 |
# Parâmetros para carregar o dataset personalizado
|
24 |
dataset_descriptions = [
|
25 |
"Images/Image01.jpg,A blonde woman wearing a blue leather jumpsuit with leather gloves the same color. She is standing with one hand on her face and the other on her waist, in a confident pose. The background is dark and neutral, highlighting the woman figure.",
|
@@ -57,6 +55,8 @@ dataset_descriptions = [
|
|
57 |
"Images/Image33.jpg,a woman on an urban street. She is wearing a red leather coat open, revealing a top that exposes her abdomen, and a short dark red leather shorts. Her hair is long and loose, and she is wearing red lipstick. The background shows a busy street with blurred shops and people."
|
58 |
]
|
59 |
|
|
|
|
|
60 |
# Definir parâmetros padrão para geração rápida
|
61 |
DEFAULT_PROMPT = "A beautiful brunette woman wearing a blue leather pants "
|
62 |
DEFAULT_INFERENCE_STEPS = 6
|
@@ -70,13 +70,6 @@ def resize_to_divisible_by_8(image):
|
|
70 |
new_height = height + (8 - height % 8) if height % 8 != 0 else height
|
71 |
return image.resize((new_width, new_height))
|
72 |
|
73 |
-
def infer_simple(prompt):
|
74 |
-
# Garantir que as dimensões sejam divisíveis por 8 antes de gerar
|
75 |
-
adjusted_height = IMAGE_HEIGHT - (IMAGE_HEIGHT % 8)
|
76 |
-
adjusted_width = IMAGE_WIDTH - (IMAGE_WIDTH % 8)
|
77 |
-
|
78 |
-
print(f"Using height: {IMAGE_HEIGHT} and width: {IMAGE_WIDTH}")
|
79 |
-
|
80 |
# Função simples para gerar imagem
|
81 |
def infer_simple(prompt):
|
82 |
# Geração da imagem
|
@@ -111,8 +104,5 @@ with gr.Blocks() as demo:
|
|
111 |
outputs=result,
|
112 |
)
|
113 |
|
114 |
-
result = gr.Image(label="Generated Image", shape=(808, 512))
|
115 |
-
|
116 |
-
|
117 |
if __name__ == "__main__":
|
118 |
demo.launch()
|
|
|
10 |
model_repo_id = "stabilityai/sdxl-turbo" # Continuando com o modelo especificado
|
11 |
|
12 |
# Carregar o pipeline configurado para CPU
|
13 |
+
pipe = DiffusionPipeline.from_pretrained(model_repo_id)
|
14 |
pipe = pipe.to(device)
|
15 |
|
|
|
|
|
|
|
16 |
# Carregando o dataset do Hugging Face
|
17 |
dataset = load_dataset("LEIDIA/Data_Womleimg")
|
18 |
|
19 |
|
20 |
+
|
21 |
# Parâmetros para carregar o dataset personalizado
|
22 |
dataset_descriptions = [
|
23 |
"Images/Image01.jpg,A blonde woman wearing a blue leather jumpsuit with leather gloves the same color. She is standing with one hand on her face and the other on her waist, in a confident pose. The background is dark and neutral, highlighting the woman figure.",
|
|
|
55 |
"Images/Image33.jpg,a woman on an urban street. She is wearing a red leather coat open, revealing a top that exposes her abdomen, and a short dark red leather shorts. Her hair is long and loose, and she is wearing red lipstick. The background shows a busy street with blurred shops and people."
|
56 |
]
|
57 |
|
58 |
+
|
59 |
+
|
60 |
# Definir parâmetros padrão para geração rápida
|
61 |
DEFAULT_PROMPT = "A beautiful brunette woman wearing a blue leather pants "
|
62 |
DEFAULT_INFERENCE_STEPS = 6
|
|
|
70 |
new_height = height + (8 - height % 8) if height % 8 != 0 else height
|
71 |
return image.resize((new_width, new_height))
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
# Função simples para gerar imagem
|
74 |
def infer_simple(prompt):
|
75 |
# Geração da imagem
|
|
|
104 |
outputs=result,
|
105 |
)
|
106 |
|
|
|
|
|
|
|
107 |
if __name__ == "__main__":
|
108 |
demo.launch()
|