barretto commited on
Commit ·
5fe576f
1
Parent(s): 962c303
first working demo
Browse files
app.py
CHANGED
|
@@ -1,22 +1,32 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
# return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
demo = gr.Interface(
|
| 8 |
-
|
| 9 |
[
|
| 10 |
gr.Radio(["Male", "Female"], label="Gender" ),
|
| 11 |
gr.Dropdown(["South Asian", "North Asian", "White", "African American", "African", "American Indian", "Hispanic"], label="Ethnicity"),
|
| 12 |
gr.Dropdown(["Black", "Brown", "Yellow", "Peach","Tan","Beige", "White", "Grey"], label="Skin color" ),
|
| 13 |
gr.Radio(["Short", "Long"], label="Hair length" ),
|
| 14 |
-
gr.Dropdown(["Black","Dark brown", "Light
|
| 15 |
gr.Dropdown(["Black", "Dark Brown", "Light Brown", "Green", "Blue", "Hazel", "Amber", "Red", "Pink"], label="Eye color" ),
|
| 16 |
-
gr.CheckboxGroup(["Nose", "Ear", "Eyebrow", "
|
| 17 |
#gr.Checkbox(label="Is it the morning?"),
|
| 18 |
],
|
| 19 |
-
|
| 20 |
# examples=[
|
| 21 |
# [2, "cat", "park", ["ran", "swam"], True],
|
| 22 |
# [4, "dog", "zoo", ["ate", "swam"], False],
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
url = "https://api.newnative.ai/stable-diffusion?prompt="
|
| 5 |
+
|
| 6 |
+
def run(gender, ethnicity, skin_color, hair_length, hair_color, eye_color, piercings):
|
| 7 |
+
prompt = f"""mugshot, {ethnicity} {skin_color} {gender} with {hair_length} {hair_color} hair, {eye_color} eyes, {" piercing, ".join([*piercings, ""]) if piercings else ""}"""
|
| 8 |
# return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
|
| 9 |
+
return getImage(prompt)
|
| 10 |
+
|
| 11 |
+
def getImage(prompt):
|
| 12 |
+
r = requests.get(url + prompt)
|
| 13 |
+
# response = requests.request("GET", url+prompt)
|
| 14 |
+
data = r.json()
|
| 15 |
+
return(data["image_url"])
|
| 16 |
|
| 17 |
demo = gr.Interface(
|
| 18 |
+
run,
|
| 19 |
[
|
| 20 |
gr.Radio(["Male", "Female"], label="Gender" ),
|
| 21 |
gr.Dropdown(["South Asian", "North Asian", "White", "African American", "African", "American Indian", "Hispanic"], label="Ethnicity"),
|
| 22 |
gr.Dropdown(["Black", "Brown", "Yellow", "Peach","Tan","Beige", "White", "Grey"], label="Skin color" ),
|
| 23 |
gr.Radio(["Short", "Long"], label="Hair length" ),
|
| 24 |
+
gr.Dropdown(["Black","Dark brown", "Light brown", "Blonde", "Red", "Grey", "Blue", "Pink"], label="Hair color" ),
|
| 25 |
gr.Dropdown(["Black", "Dark Brown", "Light Brown", "Green", "Blue", "Hazel", "Amber", "Red", "Pink"], label="Eye color" ),
|
| 26 |
+
gr.CheckboxGroup(["Nose", "Ear", "Eyebrow", "Lips", "Cheeks"], label="Piercings"),
|
| 27 |
#gr.Checkbox(label="Is it the morning?"),
|
| 28 |
],
|
| 29 |
+
"image",
|
| 30 |
# examples=[
|
| 31 |
# [2, "cat", "park", ["ran", "swam"], True],
|
| 32 |
# [4, "dog", "zoo", ["ate", "swam"], False],
|