Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -16,38 +16,30 @@ os.chdir("Stable_Diffusion_Finetuned_Minecraft_Skin_Generator")
|
|
16 |
|
17 |
|
18 |
def generate(
|
19 |
-
system_prompt,
|
20 |
prompt,
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
seed
|
27 |
):
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
if seed == 0:
|
33 |
-
seed = random.randint(1, 100000)
|
34 |
-
torch.manual_seed(seed)
|
35 |
else:
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
better_prompt = tokenizer.decode(outputs[0])
|
49 |
-
better_prompt = better_prompt.replace("<pad>", "").replace("</s>", "")
|
50 |
-
return better_prompt
|
51 |
|
52 |
|
53 |
prompt = gr.Textbox(label="Prompt", interactive=True)
|
@@ -64,6 +56,10 @@ model_precision_type = gr.Dropdown(["fp16", "fp32"], value="fp16" interactive=Tr
|
|
64 |
|
65 |
seed = gr.Number(value=42, interactive=True, label="Seed", info="A starting point to initiate the generation process, put 0 for a random one")
|
66 |
|
|
|
|
|
|
|
|
|
67 |
examples = [
|
68 |
[
|
69 |
"A man in a purple suit wearing a tophat.",
|
@@ -78,7 +74,7 @@ examples = [
|
|
78 |
|
79 |
gr.Interface(
|
80 |
fn=generate,
|
81 |
-
inputs=[prompt, stable_diffusion_model, num_inference_steps, guidance_scale, num_images_per_prompt, model_precision_type, seed],
|
82 |
outputs=gr.Image(label="Generated Minecraft Skin"),
|
83 |
title="Stable Diffusion Finetuned Minecraft Skin Generator",
|
84 |
description="Make your prompts more detailed!<br>Model used: https://huggingface.co/roborovski/superprompt-v1<br>Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)",
|
|
|
16 |
|
17 |
|
18 |
def generate(
|
|
|
19 |
prompt,
|
20 |
+
stable_diffusion_model,
|
21 |
+
num_inference_steps,
|
22 |
+
guidance_scale,
|
23 |
+
num_images_per_prompt,
|
24 |
+
model_precision_type,
|
25 |
seed
|
26 |
):
|
27 |
|
28 |
+
if verbose:
|
29 |
+
verbose_opt = '--verbose'
|
|
|
|
|
|
|
|
|
30 |
else:
|
31 |
+
verbose_opt = ''
|
32 |
|
33 |
+
if stable_diffusion_model == '2':
|
34 |
+
sd_model = "minecraft-skins"
|
35 |
+
else:
|
36 |
+
sd_model = "minecraft-skins-sdxl"
|
37 |
+
|
38 |
+
command = f"Python_Scripts/{sd_model}.py '{prompt}' {num_inference_steps} {guidance_scale} {num_images_per_prompt} {model_precision_type} {output_image_name} {verbose_opt}"
|
39 |
+
|
40 |
+
subprocess.run(["python", "$command"])
|
41 |
+
|
42 |
+
return os.path.join(f"output_minecraft_skins/{output_image_name}")
|
|
|
|
|
|
|
43 |
|
44 |
|
45 |
prompt = gr.Textbox(label="Prompt", interactive=True)
|
|
|
56 |
|
57 |
seed = gr.Number(value=42, interactive=True, label="Seed", info="A starting point to initiate the generation process, put 0 for a random one")
|
58 |
|
59 |
+
output_image_name = gr.Textbox(label="Name of Generated Skin Output", interactive=Trie, value="output.png")
|
60 |
+
|
61 |
+
verbose = gr.Checkbox(label="Verbose Output", interactive=True, value=False, info="Produce verbose output while running")
|
62 |
+
|
63 |
examples = [
|
64 |
[
|
65 |
"A man in a purple suit wearing a tophat.",
|
|
|
74 |
|
75 |
gr.Interface(
|
76 |
fn=generate,
|
77 |
+
inputs=[prompt, stable_diffusion_model, num_inference_steps, guidance_scale, num_images_per_prompt, model_precision_type, output_image_name, verbose, seed],
|
78 |
outputs=gr.Image(label="Generated Minecraft Skin"),
|
79 |
title="Stable Diffusion Finetuned Minecraft Skin Generator",
|
80 |
description="Make your prompts more detailed!<br>Model used: https://huggingface.co/roborovski/superprompt-v1<br>Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)",
|