Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,8 @@ import numpy as np
|
|
| 9 |
from diffusers import BriaFiboPipeline
|
| 10 |
from diffusers.modular_pipelines import ModularPipeline
|
| 11 |
|
|
|
|
|
|
|
| 12 |
# resolutions=[
|
| 13 |
# "832 1248",
|
| 14 |
# "896 1152",
|
|
@@ -31,7 +33,107 @@ pipe = BriaFiboPipeline.from_pretrained(
|
|
| 31 |
"briaai/FIBO",
|
| 32 |
trust_remote_code=True,
|
| 33 |
torch_dtype=dtype).to(device)
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
def handle_json(text):
|
| 37 |
try:
|
|
|
|
| 9 |
from diffusers import BriaFiboPipeline
|
| 10 |
from diffusers.modular_pipelines import ModularPipeline
|
| 11 |
|
| 12 |
+
from optimization import optimize_pipeline_
|
| 13 |
+
|
| 14 |
# resolutions=[
|
| 15 |
# "832 1248",
|
| 16 |
# "896 1152",
|
|
|
|
| 33 |
"briaai/FIBO",
|
| 34 |
trust_remote_code=True,
|
| 35 |
torch_dtype=dtype).to(device)
|
| 36 |
+
test_prompt_json =
|
| 37 |
+
"""
|
| 38 |
+
{
|
| 39 |
+
"short_description": "A surreal and whimsical scene featuring a man, a woman, and a dog posed against a tri-colored backdrop. The woman stands in front of the red section, wearing a t-shirt with a Yoda motif and a skirt with birds. The dog, dressed as a superdog, sits on a checkerboard chair in front of the white section, with a blue tennis ball in its mouth. The man, in a purple suit, stands in front of the gold section, holding a tree branch with a blue jay. The backdrop is divided into red, white, and gold sections, with a small metal grating in the top left and a tear in the gold section. A rustic framed oil painting of the pyramids hangs above the dog.",
|
| 40 |
+
"objects": [
|
| 41 |
+
{
|
| 42 |
+
"description": "A woman standing in front of the red backdrop. She is wearing a beige t-shirt with a Yoda motif and a long skirt with birds on it. Her right hand is holding an axe.",
|
| 43 |
+
"location": "Center-left",
|
| 44 |
+
"relationship": "She is positioned in front of the red backdrop and to the left of the dog and man.",
|
| 45 |
+
"relative_size": "Medium",
|
| 46 |
+
"shape_and_color": "Humanoid shape, beige and multicolored clothing.",
|
| 47 |
+
"appearance_details": "She has a long skirt with birds on it and is holding an axe.",
|
| 48 |
+
"pose": "Standing upright with a slight tilt to the right.",
|
| 49 |
+
"expression": "Neutral",
|
| 50 |
+
"clothing": "She is wearing a beige t-shirt with a Yoda motif and a long skirt with birds on it.",
|
| 51 |
+
"action": "Standing",
|
| 52 |
+
"gender": "Female",
|
| 53 |
+
"skin_tone_and_texture": "Fair, smooth."
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"description": "A dog dressed as a superdog, sitting on a checkerboard chair in front of the white backdrop. It has a blue tennis ball in its mouth.",
|
| 57 |
+
"location": "Center",
|
| 58 |
+
"relationship": "It is positioned in front of the white backdrop and between the woman and the man.",
|
| 59 |
+
"relative_size": "Medium",
|
| 60 |
+
"shape_and_color": "Canine shape, brown and white fur, blue tennis ball.",
|
| 61 |
+
"appearance_details": "It is dressed as a superdog and has a blue tennis ball in its mouth.",
|
| 62 |
+
"pose": "Sitting upright.",
|
| 63 |
+
"expression": "Neutral",
|
| 64 |
+
"clothing": "Superdog costume.",
|
| 65 |
+
"action": "Sitting",
|
| 66 |
+
"gender": "Male",
|
| 67 |
+
"skin_tone_and_texture": "Brown and white fur, soft."
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"description": "A man standing in front of the gold backdrop. He is wearing a three piece purple suit and has spiky blue hair. His left hand is holding a tree branch with a blue jay on it.",
|
| 71 |
+
"location": "Center-right",
|
| 72 |
+
"relationship": "He is positioned in front of the gold backdrop and to the right of the woman and dog.",
|
| 73 |
+
"relative_size": "Medium",
|
| 74 |
+
"shape_and_color": "Humanoid shape, purple suit, blue hair.",
|
| 75 |
+
"appearance_details": "He has spiky blue hair and is holding a tree branch with a blue jay on it.",
|
| 76 |
+
"pose": "Standing upright with a slight tilt to the left.",
|
| 77 |
+
"expression": "Neutral",
|
| 78 |
+
"clothing": "He is wearing a three piece purple suit.",
|
| 79 |
+
"action": "Standing",
|
| 80 |
+
"gender": "Male",
|
| 81 |
+
"skin_tone_and_texture": "Fair, smooth."
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"description": "A checkerboard armchair in yellow and brown.",
|
| 85 |
+
"location": "Bottom-center",
|
| 86 |
+
"relationship": "The dog is sitting on the chair.",
|
| 87 |
+
"relative_size": "Small",
|
| 88 |
+
"shape_and_color": "Chair shape, yellow and brown.",
|
| 89 |
+
"texture": "Smooth. End of texture answer.",
|
| 90 |
+
"appearance_details": "The chair is a checkerboard armchair in yellow and brown."
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"description": "A rustic framed oil painting of the pyramids.",
|
| 94 |
+
"location": "Top-center",
|
| 95 |
+
"relationship": "The painting is hanging above the dog.",
|
| 96 |
+
"relative_size": "Small",
|
| 97 |
+
"shape_and_color": "Rectangular shape, brown frame, yellow and brown pyramids.",
|
| 98 |
+
"texture": "Rough. End of texture answer.",
|
| 99 |
+
"appearance_details": "The painting is a rustic framed oil painting of the pyramids."
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
"background_setting": "The background is a tri-colored backdrop divided equally into red, white, and gold sections. There is a small rectangular metal grating in the top left corner and a subtle tear in the gold backdrop in the bottom right corner.",
|
| 103 |
+
"lighting": {
|
| 104 |
+
"conditions": "Studio lighting",
|
| 105 |
+
"direction": "Front-lit",
|
| 106 |
+
"shadows": "Soft shadows are present, indicating diffused lighting."
|
| 107 |
+
},
|
| 108 |
+
"aesthetics": {
|
| 109 |
+
"composition": "The composition is centered, with the three figures arranged in a row. The backdrop is divided into thirds, creating a symmetrical balance.",
|
| 110 |
+
"color_scheme": "The color scheme is triadic, with red, white, and gold dominating the backdrop, complemented by the various colors of the figures' clothing and accessories.",
|
| 111 |
+
"mood_atmosphere": "The mood is whimsical and surreal, with a touch of humor due to the unusual costumes and props.",
|
| 112 |
+
"preference_score": "high",
|
| 113 |
+
"aesthetic_score": "high"
|
| 114 |
+
},
|
| 115 |
+
"photographic_characteristics": {
|
| 116 |
+
"depth_of_field": "Deep",
|
| 117 |
+
"focus": "Sharp focus on all subjects",
|
| 118 |
+
"camera_angle": "Eye-level",
|
| 119 |
+
"lens_focal_length": "Standard"
|
| 120 |
+
},
|
| 121 |
+
"style_medium": "Photograph",
|
| 122 |
+
"text_render": [
|
| 123 |
+
{
|
| 124 |
+
"text": "Yoda",
|
| 125 |
+
"location": "Center of the woman's t-shirt",
|
| 126 |
+
"size": "Small",
|
| 127 |
+
"color": "Beige",
|
| 128 |
+
"font": "Cartoonish",
|
| 129 |
+
"appearance_details": "The text is part of a graphic design on the t-shirt."
|
| 130 |
+
}
|
| 131 |
+
],
|
| 132 |
+
"context": "This is a surreal and whimsical portrait of a man, a woman, and a dog posed against a tri-colored backdrop. It could be an art piece or a promotional image for a quirky event or product.",
|
| 133 |
+
"artistic_style": "Surreal Pop"
|
| 134 |
+
}
|
| 135 |
+
"""
|
| 136 |
+
optimize_pipeline_(pipe, test_prompt_json)
|
| 137 |
|
| 138 |
def handle_json(text):
|
| 139 |
try:
|