Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ warnings.filterwarnings("ignore")
|
|
| 10 |
|
| 11 |
model_path = "Disty0/NewBie-image-Exp0.1-Diffusers" # NewBie-AI/NewBie-image-Exp0.1
|
| 12 |
|
| 13 |
-
print("
|
| 14 |
text_encoder_2 = AutoModel.from_pretrained(
|
| 15 |
model_path,
|
| 16 |
subfolder="text_encoder_2",
|
|
@@ -18,7 +18,7 @@ text_encoder_2 = AutoModel.from_pretrained(
|
|
| 18 |
torch_dtype=torch.bfloat16
|
| 19 |
)
|
| 20 |
|
| 21 |
-
print("
|
| 22 |
pipe_newbie = NewbiePipeline.from_pretrained(
|
| 23 |
model_path,
|
| 24 |
text_encoder_2=text_encoder_2,
|
|
@@ -28,7 +28,7 @@ pipe_newbie.to("cuda")
|
|
| 28 |
|
| 29 |
del text_encoder_2
|
| 30 |
torch.cuda.empty_cache()
|
| 31 |
-
print("
|
| 32 |
|
| 33 |
@spaces.GPU()
|
| 34 |
def generate_image_newbie(prompt, negative_prompt, height, width, num_inference_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
|
@@ -72,40 +72,40 @@ newbie_prompt = """<character_1>
|
|
| 72 |
<other>2024_year</other>
|
| 73 |
</general_tags>"""
|
| 74 |
|
| 75 |
-
with gr.Blocks(title="NewBie
|
| 76 |
-
gr.Markdown("# NewBie
|
| 77 |
-
gr.Markdown("
|
| 78 |
|
| 79 |
with gr.Row(variant="panel"):
|
| 80 |
with gr.Column(scale=2):
|
| 81 |
prompt_newbie = gr.Textbox(
|
| 82 |
-
label="
|
| 83 |
value=newbie_prompt,
|
| 84 |
lines=10,
|
| 85 |
-
placeholder="
|
| 86 |
)
|
| 87 |
negative_prompt_newbie = gr.Textbox(
|
| 88 |
-
label="
|
| 89 |
value="low quality, bad quality, blurry, low resolution, deformed, ugly, bad anatomy",
|
| 90 |
lines=3,
|
| 91 |
-
placeholder="
|
| 92 |
)
|
| 93 |
|
| 94 |
with gr.Row():
|
| 95 |
-
height_newbie = gr.Slider(label="
|
| 96 |
-
width_newbie = gr.Slider(label="
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
-
steps_newbie = gr.Slider(label="
|
| 100 |
-
guidance_scale_newbie = gr.Slider(label="
|
| 101 |
|
| 102 |
-
seed_newbie = gr.Number(label="
|
| 103 |
|
| 104 |
-
generate_btn_newbie = gr.Button("
|
| 105 |
|
| 106 |
with gr.Column(scale=1):
|
| 107 |
-
image_output_newbie = gr.Image(label="
|
| 108 |
-
used_seed_newbie = gr.Number(label="
|
| 109 |
|
| 110 |
generate_btn_newbie.click(
|
| 111 |
fn=generate_image_newbie,
|
|
|
|
| 10 |
|
| 11 |
model_path = "Disty0/NewBie-image-Exp0.1-Diffusers" # NewBie-AI/NewBie-image-Exp0.1
|
| 12 |
|
| 13 |
+
print("Text Encoder...")
|
| 14 |
text_encoder_2 = AutoModel.from_pretrained(
|
| 15 |
model_path,
|
| 16 |
subfolder="text_encoder_2",
|
|
|
|
| 18 |
torch_dtype=torch.bfloat16
|
| 19 |
)
|
| 20 |
|
| 21 |
+
print("Pipeline...")
|
| 22 |
pipe_newbie = NewbiePipeline.from_pretrained(
|
| 23 |
model_path,
|
| 24 |
text_encoder_2=text_encoder_2,
|
|
|
|
| 28 |
|
| 29 |
del text_encoder_2
|
| 30 |
torch.cuda.empty_cache()
|
| 31 |
+
print("Completed")
|
| 32 |
|
| 33 |
@spaces.GPU()
|
| 34 |
def generate_image_newbie(prompt, negative_prompt, height, width, num_inference_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 72 |
<other>2024_year</other>
|
| 73 |
</general_tags>"""
|
| 74 |
|
| 75 |
+
with gr.Blocks(title="NewBie") as demo:
|
| 76 |
+
gr.Markdown("# NewBie Image Generator)")
|
| 77 |
+
gr.Markdown("Generate high-quality anime-style images using the NewBie model.")
|
| 78 |
|
| 79 |
with gr.Row(variant="panel"):
|
| 80 |
with gr.Column(scale=2):
|
| 81 |
prompt_newbie = gr.Textbox(
|
| 82 |
+
label="Prompt",
|
| 83 |
value=newbie_prompt,
|
| 84 |
lines=10,
|
| 85 |
+
placeholder="Enter the prompt here..."
|
| 86 |
)
|
| 87 |
negative_prompt_newbie = gr.Textbox(
|
| 88 |
+
label="Negative Prompt",
|
| 89 |
value="low quality, bad quality, blurry, low resolution, deformed, ugly, bad anatomy",
|
| 90 |
lines=3,
|
| 91 |
+
placeholder="Enter the elements that should not appear here..."
|
| 92 |
)
|
| 93 |
|
| 94 |
with gr.Row():
|
| 95 |
+
height_newbie = gr.Slider(label="Height", minimum=512, maximum=2048, step=64, value=1024)
|
| 96 |
+
width_newbie = gr.Slider(label="Width", minimum=512, maximum=2048, step=64, value=1024)
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
+
steps_newbie = gr.Slider(label="Inference Steps", minimum=1, maximum=100, step=1, value=28)
|
| 100 |
+
guidance_scale_newbie = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=20.0, step=0.1, value=3.5)
|
| 101 |
|
| 102 |
+
seed_newbie = gr.Number(label="Seed, -1 is random", value=-1, precision=0)
|
| 103 |
|
| 104 |
+
generate_btn_newbie = gr.Button("Generate", variant="primary")
|
| 105 |
|
| 106 |
with gr.Column(scale=1):
|
| 107 |
+
image_output_newbie = gr.Image(label="Output", format="png", interactive=False)
|
| 108 |
+
used_seed_newbie = gr.Number(label="Used Seed", interactive=False)
|
| 109 |
|
| 110 |
generate_btn_newbie.click(
|
| 111 |
fn=generate_image_newbie,
|