Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,8 @@ import random
|
|
13 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
14 |
|
15 |
MODELS = ["stabilityai/stable-diffusion-2-1", "stabilityai/stable-diffusion-2-1-base", "stabilityai/stable-diffusion-2"]
|
|
|
|
|
16 |
|
17 |
#word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
18 |
#word_list = word_list_dataset["train"]['text']
|
@@ -34,7 +36,9 @@ def infer(prompt, negative, scale, model_id=MODELS[0], hf_token="", images=[]):
|
|
34 |
client = InferenceClient(model=model_id, token=hf_token)
|
35 |
for i in range(4):
|
36 |
image = client.text_to_image(prompt=prompt, negative_prompt=negative, guidance_scale=scale, num_inference_steps=45, seed=gen_random_seed())
|
37 |
-
|
|
|
|
|
38 |
yield images
|
39 |
#payload = {'prompt': prompt, 'negative_prompt': negative, 'guidance_scale': scale}
|
40 |
#images_request = requests.post(url, json = payload)
|
@@ -56,7 +60,9 @@ def infer_advance(prompt, negative, scale, width, height, steps, seed, samples,
|
|
56 |
for i in range(samples):
|
57 |
image = client.text_to_image(prompt=prompt, negative_prompt=negative, width=width, height=height,
|
58 |
guidance_scale=scale, num_inference_steps=steps, seed=seed if i==0 else gen_random_seed())
|
59 |
-
|
|
|
|
|
60 |
yield images
|
61 |
|
62 |
css = """
|
|
|
13 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
14 |
|
15 |
MODELS = ["stabilityai/stable-diffusion-2-1", "stabilityai/stable-diffusion-2-1-base", "stabilityai/stable-diffusion-2"]
|
16 |
+
OUTPUT_PATH = ".output"
|
17 |
+
os.makedirs(OUTPUT_PATH, exist_ok=True)
|
18 |
|
19 |
#word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
|
20 |
#word_list = word_list_dataset["train"]['text']
|
|
|
36 |
client = InferenceClient(model=model_id, token=hf_token)
|
37 |
for i in range(4):
|
38 |
image = client.text_to_image(prompt=prompt, negative_prompt=negative, guidance_scale=scale, num_inference_steps=45, seed=gen_random_seed())
|
39 |
+
file_path = f"{OUTPUT_PATH}/{uuid.uuid4()}.jpg"
|
40 |
+
image.save(file_path)
|
41 |
+
if image: images.append(file_path)
|
42 |
yield images
|
43 |
#payload = {'prompt': prompt, 'negative_prompt': negative, 'guidance_scale': scale}
|
44 |
#images_request = requests.post(url, json = payload)
|
|
|
60 |
for i in range(samples):
|
61 |
image = client.text_to_image(prompt=prompt, negative_prompt=negative, width=width, height=height,
|
62 |
guidance_scale=scale, num_inference_steps=steps, seed=seed if i==0 else gen_random_seed())
|
63 |
+
file_path = f"{OUTPUT_PATH}/{uuid.uuid4()}.jpg"
|
64 |
+
image.save(file_path)
|
65 |
+
if image: images.append(file_path)
|
66 |
yield images
|
67 |
|
68 |
css = """
|