barretto commited on
Commit
3fbc1dd
·
1 Parent(s): 1b79434

Updating prompt generation and validation

Browse files
Files changed (2) hide show
  1. README.md +6 -2
  2. app.py +2 -4
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Test Space
3
  emoji: 🌍
4
  colorFrom: purple
5
  colorTo: green
@@ -21,6 +21,10 @@ run app.py
21
  python app.py
22
  ```
23
 
24
- open
 
 
 
 
25
 
26
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Portrait Generator
3
  emoji: 🌍
4
  colorFrom: purple
5
  colorTo: green
 
21
  python app.py
22
  ```
23
 
24
+ open
25
+ ```
26
+ http://127.0.0.1:7860
27
+ ```
28
+
29
 
30
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -4,10 +4,8 @@ import requests
4
  url = "https://api.newnative.ai/stable-diffusion?prompt="
5
 
6
  def run(gender, height, weight, age, ethnicity, skin_color, hair_length, hair_color, eye_color, facial_hair, facial_hair_color):
7
- prompt = f"""mugshot portrait, {ethnicity} {skin_color} {gender} with {hair_length} {hair_color} hair, {eye_color} eyes, {facial_hair} {facial_hair_color} facial hair, {age} years old, {getHeightInFeet(height)} tall, {getWeightInPounds(weight)}"""
8
 
9
- # prompt = f"""mugshot portrait, {ethnicity} {skin_color} {gender} with {hair_length} {hair_color} hair, {eye_color} eyes, {" piercing, ".join([*piercings, ""]) if piercings else ""}"""
10
- # return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
11
  print (prompt)
12
  return getImage(prompt)
13
 
@@ -31,7 +29,7 @@ demo = gr.Interface(
31
  gr.Slider(100,250,value=160, label="Height (cm)"), #Height
32
  gr.Slider(40,250,value=50, label="Weight (kg)"), #Weight
33
  gr.Radio(sorted(["Young", "Adult", "Middle-aged", "Old"]), label="Age" ), #Age
34
- gr.Dropdown(sorted(["South Asian", "North Asian", "White", "African American", "African", "American Indian", "Hispanic"]), label="Ethnicity"), #Ethnicity
35
  gr.Dropdown(sorted(["Black", "Brown", "Yellow", "Peach","Tan","Beige", "White", "Grey"]), label="Skin color" ), #Skin color
36
  gr.Radio(sorted(["Short", "Long", "Bald", "Medium"]), label="Hair length" ), #Hair length
37
  gr.Dropdown(sorted(["Black","Dark brown", "Light brown", "Blonde", "Red", "Grey"]), label="Hair color" ), #Hair color
 
4
  url = "https://api.newnative.ai/stable-diffusion?prompt="
5
 
6
  def run(gender, height, weight, age, ethnicity, skin_color, hair_length, hair_color, eye_color, facial_hair, facial_hair_color):
7
+ prompt = f"""mugshot portrait, {skin_color} {ethnicity} {gender}{" with " + hair_length if hair_length else ""} {hair_color + " hair, " if hair_length and hair_color else ""}{eye_color + " eyes, " if eye_color else ""}{facial_hair_color + " " if facial_hair and facial_hair_color else ""}{facial_hair+ ", " if facial_hair else ""}{age + ", " if age else ""}{getHeightInFeet(height) + " tall, " if height else ""}{getWeightInPounds(weight)}"""
8
 
 
 
9
  print (prompt)
10
  return getImage(prompt)
11
 
 
29
  gr.Slider(100,250,value=160, label="Height (cm)"), #Height
30
  gr.Slider(40,250,value=50, label="Weight (kg)"), #Weight
31
  gr.Radio(sorted(["Young", "Adult", "Middle-aged", "Old"]), label="Age" ), #Age
32
+ gr.Dropdown(sorted(["South Asian", "North Asian", "White", "African American", "American Indian", "Hispanic"]), label="Ethnicity"), #Ethnicity
33
  gr.Dropdown(sorted(["Black", "Brown", "Yellow", "Peach","Tan","Beige", "White", "Grey"]), label="Skin color" ), #Skin color
34
  gr.Radio(sorted(["Short", "Long", "Bald", "Medium"]), label="Hair length" ), #Hair length
35
  gr.Dropdown(sorted(["Black","Dark brown", "Light brown", "Blonde", "Red", "Grey"]), label="Hair color" ), #Hair color