Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,6 @@ from huggingface_hub import InferenceClient
|
|
3 |
from gradio_client import Client
|
4 |
import re
|
5 |
|
6 |
-
# Set page configuration
|
7 |
-
st.set_page_config(layout="wide")
|
8 |
-
|
9 |
# Load custom CSS
|
10 |
with open('style.css') as f:
|
11 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
@@ -90,6 +87,7 @@ def generate_image(prompt):
|
|
90 |
return None
|
91 |
|
92 |
def main():
|
|
|
93 |
st.title("Free Waifu Character Generator")
|
94 |
st.write("""
|
95 |
Welcome to the Free Waifu Character Generator! This app allows you to create a unique waifu with just one click.
|
@@ -142,46 +140,41 @@ def main():
|
|
142 |
|
143 |
# Generate button
|
144 |
if st.button("Generate Waifu"):
|
145 |
-
with
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
st.success("Waifu character generated!")
|
167 |
|
168 |
with right_col:
|
169 |
st.header("Generated Waifu")
|
170 |
-
# Display the generated image
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
if st.session_state.image_paths:
|
172 |
st.subheader("Generated Image")
|
173 |
for image_path in st.session_state.image_paths:
|
174 |
st.image(image_path, caption="Generated Waifu Image")
|
175 |
|
176 |
-
# Display the generated image prompt
|
177 |
-
if st.session_state.image_prompt:
|
178 |
-
st.subheader("Image Prompt")
|
179 |
-
st.write(st.session_state.image_prompt)
|
180 |
-
|
181 |
-
# Display the generated character description
|
182 |
-
if st.session_state.character_description:
|
183 |
-
st.subheader("Generated Waifu Character")
|
184 |
-
st.write(st.session_state.character_description)
|
185 |
-
|
186 |
if __name__ == "__main__":
|
187 |
main()
|
|
|
3 |
from gradio_client import Client
|
4 |
import re
|
5 |
|
|
|
|
|
|
|
6 |
# Load custom CSS
|
7 |
with open('style.css') as f:
|
8 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
|
|
87 |
return None
|
88 |
|
89 |
def main():
|
90 |
+
st.set_page_config(layout="wide")
|
91 |
st.title("Free Waifu Character Generator")
|
92 |
st.write("""
|
93 |
Welcome to the Free Waifu Character Generator! This app allows you to create a unique waifu with just one click.
|
|
|
140 |
|
141 |
# Generate button
|
142 |
if st.button("Generate Waifu"):
|
143 |
+
with st.spinner("Generating waifu character..."):
|
144 |
+
description_prompt = format_prompt_for_description(
|
145 |
+
name, hair_color, personality, outfit_style, hobbies, favorite_food, background_story,
|
146 |
+
eye_color=eye_color, height=height, age=age, favorite_quote=favorite_quote, strengths=strengths,
|
147 |
+
weaknesses=weaknesses, goals=goals
|
148 |
+
)
|
149 |
+
image_prompt = format_prompt_for_image(
|
150 |
+
name, hair_color, personality, outfit_style,
|
151 |
+
background_setting=background_setting, pose=pose
|
152 |
+
)
|
153 |
+
|
154 |
+
# Generate character description
|
155 |
+
st.session_state.character_description = generate_text(description_prompt, temperature, max_new_tokens, top_p, repetition_penalty)
|
156 |
+
|
157 |
+
# Generate image prompt
|
158 |
+
st.session_state.image_prompt = generate_text(image_prompt, temperature, max_new_tokens, top_p, repetition_penalty)
|
159 |
+
|
160 |
+
# Generate image from image prompt
|
161 |
+
st.session_state.image_paths = generate_image(st.session_state.image_prompt)
|
162 |
+
|
163 |
+
st.success("Waifu character generated!")
|
|
|
164 |
|
165 |
with right_col:
|
166 |
st.header("Generated Waifu")
|
167 |
+
# Display the generated character and image prompt
|
168 |
+
if st.session_state.character_description:
|
169 |
+
st.subheader("Generated Waifu Character")
|
170 |
+
st.write(st.session_state.character_description)
|
171 |
+
if st.session_state.image_prompt:
|
172 |
+
st.subheader("Image Prompt")
|
173 |
+
st.write(st.session_state.image_prompt)
|
174 |
if st.session_state.image_paths:
|
175 |
st.subheader("Generated Image")
|
176 |
for image_path in st.session_state.image_paths:
|
177 |
st.image(image_path, caption="Generated Waifu Image")
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
if __name__ == "__main__":
|
180 |
main()
|