Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,37 +24,28 @@ def load_pipeline(use_cuda):
|
|
24 |
pipe.to(device)
|
25 |
return pipe
|
26 |
|
27 |
-
def generate_image(prompt, use_details,
|
28 |
pipe = load_pipeline(use_cuda)
|
29 |
-
generator = torch.manual_seed(
|
30 |
extended_prompt = extend_prompt(prompt) if use_details else prompt
|
31 |
-
image = pipe(prompt=extended_prompt, generator=generator, num_inference_steps=
|
32 |
return image, extended_prompt
|
33 |
|
34 |
-
#
|
35 |
-
st.markdown("""
|
36 |
-
<style>
|
37 |
-
body {background-color: #E8F5E9;}
|
38 |
-
.header {font-size: 2.5em; color: #2E7D32; text-align: center; margin-top: 20px;}
|
39 |
-
.subheader {font-size: 1.2em; color: #4CAF50; text-align: center; margin-bottom: 30px;}
|
40 |
-
</style>
|
41 |
-
""", unsafe_allow_html=True)
|
42 |
|
43 |
st.markdown("<div class='header'>β¨ Generate Your Custom GitHub Profile Picture! β¨</div>", unsafe_allow_html=True)
|
44 |
st.markdown("<div class='subheader'>Create an anime-style GitHub profile picture that reflects your personality and passion for coding. ππ¨βπ»</div>", unsafe_allow_html=True)
|
45 |
|
46 |
# Input widgets
|
47 |
-
input_text = st.text_area("Describe your GitHub profile picture:",
|
48 |
-
"Create an anime-style GitHub profile picture for a boy. The character should have a friendly and approachable expression, embodying a sense of curiosity and enthusiasm, reflecting the qualities of a passionate coder. Incorporate elements that suggest technology or coding, such as a pair of stylish glasses, a laptop, or a background with subtle code or tech motifs. Use vibrant and appealing colors to make the profile picture stand out and convey a sense of creativity and innovation.")
|
49 |
|
50 |
details_checkbox = st.checkbox("Generate Details?", value=True)
|
51 |
-
steps_slider = st.slider("Number of Iterations", min_value=1, max_value=50, value=25, step=1)
|
52 |
-
seed_slider = st.slider("Seed", min_value=0, max_value=9007199254740991, value=3982317, step=1)
|
53 |
cuda_checkbox = st.checkbox("Use CUDA?", value=False)
|
54 |
|
55 |
if st.button("Generate Image"):
|
56 |
with st.spinner('Generating image...'):
|
57 |
-
image, extended_prompt = generate_image(input_text, details_checkbox,
|
58 |
st.image(image, caption="Generated Image")
|
59 |
st.text(f"Extended Prompt: {extended_prompt}")
|
60 |
st.balloons()
|
|
|
24 |
pipe.to(device)
|
25 |
return pipe
|
26 |
|
27 |
+
def generate_image(prompt, use_details, use_cuda):
|
28 |
pipe = load_pipeline(use_cuda)
|
29 |
+
generator = torch.manual_seed(np.random.randint(0, 2**32))
|
30 |
extended_prompt = extend_prompt(prompt) if use_details else prompt
|
31 |
+
image = pipe(prompt=extended_prompt, generator=generator, num_inference_steps=25, guidance_scale=7.5).images[0]
|
32 |
return image, extended_prompt
|
33 |
|
34 |
+
# Add the custom CSS file
|
35 |
+
st.markdown('<link rel="stylesheet" href="styles.css">', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
st.markdown("<div class='header'>β¨ Generate Your Custom GitHub Profile Picture! β¨</div>", unsafe_allow_html=True)
|
38 |
st.markdown("<div class='subheader'>Create an anime-style GitHub profile picture that reflects your personality and passion for coding. ππ¨βπ»</div>", unsafe_allow_html=True)
|
39 |
|
40 |
# Input widgets
|
41 |
+
input_text = st.text_area("Describe your GitHub profile picture:", "Create an anime-style GitHub profile picture for a boy")
|
|
|
42 |
|
43 |
details_checkbox = st.checkbox("Generate Details?", value=True)
|
|
|
|
|
44 |
cuda_checkbox = st.checkbox("Use CUDA?", value=False)
|
45 |
|
46 |
if st.button("Generate Image"):
|
47 |
with st.spinner('Generating image...'):
|
48 |
+
image, extended_prompt = generate_image(input_text, details_checkbox, cuda_checkbox)
|
49 |
st.image(image, caption="Generated Image")
|
50 |
st.text(f"Extended Prompt: {extended_prompt}")
|
51 |
st.balloons()
|