Spaces:
Sleeping
Sleeping
File size: 2,717 Bytes
9c70942 47e5483 9c70942 b8ce1af 9c70942 47e5483 9c70942 b8ce1af 47e5483 9c70942 47e5483 b8ce1af 47e5483 9c70942 47e5483 9c70942 b8ce1af 9c70942 47e5483 b8ce1af 9c70942 47e5483 b8ce1af 9c70942 47e5483 9c70942 47e5483 9c70942 47e5483 9c70942 b8ce1af 47e5483 b8ce1af 47e5483 b8ce1af 9c70942 47e5483 b8ce1af 47e5483 9c70942 47e5483 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | import gradio as gr
from optimum.intel.openvino import OVStableDiffusionPipeline
# model AI
model_id = "segmind/tiny-sd"
pipe = OVStableDiffusionPipeline.from_pretrained(
model_id,
export=True
)
# fungsi generate
def generate_image(prompt, steps, width, height):
image = pipe(
prompt,
negative_prompt="blurry, bad quality, low quality",
num_inference_steps=int(steps),
width=int(width),
height=int(height)
).images[0]
return image
# custom css aesthetic
custom_css = """
body {
background: #0f1117;
}
.gradio-container {
background: linear-gradient(
135deg,
#0f1117,
#1c1f2b
);
color: white;
}
h1 {
text-align: center;
font-size: 42px !important;
font-weight: bold;
background: linear-gradient(to right, #8b5cf6, #ec4899);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
textarea {
background: #1e2230 !important;
color: white !important;
border-radius: 15px !important;
}
button {
background: linear-gradient(
to right,
#8b5cf6,
#ec4899
) !important;
color: white !important;
border: none !important;
border-radius: 14px !important;
font-size: 18px !important;
padding: 12px !important;
}
footer {
display: none !important;
}
"""
# UI website
with gr.Blocks(
css=custom_css,
theme=gr.themes.Soft()
) as app:
gr.Markdown("""
# ✨ Pudel AI Generator
Create beautiful AI images instantly
""")
with gr.Row():
with gr.Column(scale=1):
prompt = gr.Textbox(
label="Prompt",
placeholder="contoh: anime girl cyberpunk"
)
steps = gr.Slider(
10,
50,
value=20,
step=1,
label="Steps"
)
width = gr.Slider(
256,
1024,
value=512,
step=64,
label="Width"
)
height = gr.Slider(
256,
1024,
value=512,
step=64,
label="Height"
)
generate_btn = gr.Button(
"✨ Generate Image"
)
with gr.Column(scale=1):
output = gr.Image(
label="Hasil AI",
type="filepath",
height=500
)
generate_btn.click(
fn=generate_image,
inputs=[
prompt,
steps,
width,
height
],
outputs=output
)
app.launch() |