randeom commited on
Commit
d8dd717
·
verified ·
1 Parent(s): a73ddf4

Update app.py

Browse files

This updated code includes additional character attributes, personality details, and more detailed image generation options, giving users a richer and more customizable experience.

Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -11,13 +11,16 @@ with open('style.css') as f:
11
  text_client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.1")
12
  image_client = Client("Boboiazumi/animagine-xl-3.1")
13
 
14
- def format_prompt_for_description(name, hair_color, personality, outfit_style, hobbies, favorite_food, background_story):
15
- prompt = f"Create a waifu character named {name} with {hair_color} hair, a {personality} personality, and wearing a {outfit_style}. "
16
- prompt += f"Her hobbies include {hobbies}. Her favorite food is {favorite_food}. Here is her background story: {background_story}."
 
 
17
  return prompt
18
 
19
- def format_prompt_for_image(name, hair_color, personality, outfit_style):
20
- prompt = f"Generate an image prompt for a waifu character named {name} with {hair_color} hair, a {personality} personality, and wearing a {outfit_style}."
 
21
  return prompt
22
 
23
  def clean_generated_text(text):
@@ -83,19 +86,33 @@ def generate_image(prompt):
83
  return None
84
 
85
  def main():
86
- st.title("Enhanced Waifu Character Generator")
 
 
 
 
 
87
 
88
  # User inputs
89
  col1, col2 = st.columns(2)
90
  with col1:
91
  name = st.text_input("Name of the Waifu")
92
  hair_color = st.selectbox("Hair Color", ["Blonde", "Brunette", "Red", "Black", "Blue", "Pink"])
 
 
 
93
  personality = st.selectbox("Personality", ["Tsundere", "Yandere", "Kuudere", "Dandere", "Genki", "Normal"])
94
  outfit_style = st.selectbox("Outfit Style", ["School Uniform", "Maid Outfit", "Casual", "Kimono", "Gothic Lolita"])
95
  with col2:
96
  hobbies = st.text_input("Hobbies")
97
  favorite_food = st.text_input("Favorite Food")
 
 
 
 
98
  background_story = st.text_area("Background Story")
 
 
99
  system_prompt = st.text_input("Optional System Prompt", "")
100
 
101
  # Advanced settings
@@ -116,8 +133,11 @@ def main():
116
  # Generate button
117
  if st.button("Generate Waifu"):
118
  with st.spinner("Generating waifu character..."):
119
- description_prompt = format_prompt_for_description(name, hair_color, personality, outfit_style, hobbies, favorite_food, background_story)
120
- image_prompt = format_prompt_for_image(name, hair_color, personality, outfit_style)
 
 
 
121
 
122
  # Generate character description
123
  st.session_state.character_description = generate_text(description_prompt, temperature, max_new_tokens, top_p, repetition_penalty)
 
11
  text_client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.1")
12
  image_client = Client("Boboiazumi/animagine-xl-3.1")
13
 
14
+ def format_prompt_for_description(name, hair_color, eye_color, height, age, personality, outfit_style, hobbies, favorite_food, favorite_quote, strengths, weaknesses, goals, background_story):
15
+ prompt = f"Create a waifu character named {name} with {hair_color} hair, {eye_color} eyes, a {personality} personality, and wearing a {outfit_style}. "
16
+ prompt += f"She is {height} tall and {age} years old. Her hobbies include {hobbies}. Her favorite food is {favorite_food}. "
17
+ prompt += f"Her favorite quote is: '{favorite_quote}'. She has the following strengths: {strengths}. Her weaknesses include {weaknesses}. "
18
+ prompt += f"Her goals are: {goals}. Here is her background story: {background_story}."
19
  return prompt
20
 
21
+ def format_prompt_for_image(name, hair_color, eye_color, personality, outfit_style, background_setting, pose):
22
+ prompt = f"Generate an image prompt for a waifu character named {name} with {hair_color} hair, {eye_color} eyes, a {personality} personality, and wearing a {outfit_style}. "
23
+ prompt += f"She is in a {background_setting} setting, posing in a {pose}."
24
  return prompt
25
 
26
  def clean_generated_text(text):
 
86
  return None
87
 
88
  def main():
89
+ st.title("Free Waifu Character Generator")
90
+ st.write("""
91
+ Welcome to the Free Waifu Character Generator! This app allows you to create a unique waifu with just one click.
92
+ Generate a detailed bio/background story, a prompt for an image, and the image itself.
93
+ It's the best free waifu generator out there, providing everything you need to bring your waifu to life.
94
+ """)
95
 
96
  # User inputs
97
  col1, col2 = st.columns(2)
98
  with col1:
99
  name = st.text_input("Name of the Waifu")
100
  hair_color = st.selectbox("Hair Color", ["Blonde", "Brunette", "Red", "Black", "Blue", "Pink"])
101
+ eye_color = st.selectbox("Eye Color", ["Blue", "Green", "Brown", "Hazel", "Red", "Purple"])
102
+ height = st.text_input("Height (e.g., 5'6\")")
103
+ age = st.text_input("Age")
104
  personality = st.selectbox("Personality", ["Tsundere", "Yandere", "Kuudere", "Dandere", "Genki", "Normal"])
105
  outfit_style = st.selectbox("Outfit Style", ["School Uniform", "Maid Outfit", "Casual", "Kimono", "Gothic Lolita"])
106
  with col2:
107
  hobbies = st.text_input("Hobbies")
108
  favorite_food = st.text_input("Favorite Food")
109
+ favorite_quote = st.text_input("Favorite Quote")
110
+ strengths = st.text_input("Strengths")
111
+ weaknesses = st.text_input("Weaknesses")
112
+ goals = st.text_input("Goals")
113
  background_story = st.text_area("Background Story")
114
+ background_setting = st.selectbox("Background Setting", ["School", "City", "Fantasy World", "Beach", "Park"])
115
+ pose = st.selectbox("Pose", ["Standing", "Sitting", "Action Pose", "Lying Down"])
116
  system_prompt = st.text_input("Optional System Prompt", "")
117
 
118
  # Advanced settings
 
133
  # Generate button
134
  if st.button("Generate Waifu"):
135
  with st.spinner("Generating waifu character..."):
136
+ description_prompt = format_prompt_for_description(
137
+ name, hair_color, eye_color, height, age, personality, outfit_style,
138
+ hobbies, favorite_food, favorite_quote, strengths, weaknesses, goals, background_story
139
+ )
140
+ image_prompt = format_prompt_for_image(name, hair_color, eye_color, personality, outfit_style, background_setting, pose)
141
 
142
  # Generate character description
143
  st.session_state.character_description = generate_text(description_prompt, temperature, max_new_tokens, top_p, repetition_penalty)