Spaces:
Running
on
Zero
Running
on
Zero
wuwenxu.01
commited on
Commit
·
9d31e57
1
Parent(s):
3408cd5
feat: examples table
Browse files- .gitattributes +2 -0
- app.py +43 -1
- assets/examples/1one2one/config.json +8 -0
- assets/examples/1one2one/ref1.jpg +3 -0
- assets/examples/1one2one/result.png +3 -0
- assets/examples/2one2one/config.json +8 -0
- assets/examples/2one2one/ref1.png +3 -0
- assets/examples/2one2one/result.png +3 -0
- assets/examples/3one2one/config.json +8 -0
- assets/examples/3one2one/ref1.png +3 -0
- assets/examples/3one2one/result.png +3 -0
- assets/examples/4two2one/config.json +9 -0
- assets/examples/4two2one/ref1.png +3 -0
- assets/examples/4two2one/ref2.png +3 -0
- assets/examples/4two2one/result.png +3 -0
- assets/examples/5two2one/config.json +9 -0
- assets/examples/5two2one/ref1.png +3 -0
- assets/examples/5two2one/ref2.png +3 -0
- assets/examples/5two2one/result.png +3 -0
- assets/examples/6many2one/config.json +10 -0
- assets/examples/6many2one/ref1.png +3 -0
- assets/examples/6many2one/ref2.png +3 -0
- assets/examples/6many2one/ref3.png +3 -0
- assets/examples/6many2one/result.png +3 -0
- assets/examples/7t2i/config.json +7 -0
- assets/examples/7t2i/result.png +3 -0
- requirements.txt +0 -1
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -13,6 +13,8 @@
|
|
| 13 |
# limitations under the License.
|
| 14 |
|
| 15 |
import dataclasses
|
|
|
|
|
|
|
| 16 |
|
| 17 |
import gradio as gr
|
| 18 |
import torch
|
|
@@ -20,6 +22,33 @@ import spaces
|
|
| 20 |
|
| 21 |
from uno.flux.pipeline import UNOPipeline
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def create_demo(
|
| 25 |
model_type: str,
|
|
@@ -45,7 +74,7 @@ def create_demo(
|
|
| 45 |
ref_long_side = gr.Slider(128, 512, 512, step=16, label="Long side of Ref Images")
|
| 46 |
with gr.Column():
|
| 47 |
gr.Markdown("📌 **The recommended ref scale** is related to the ref img number.\n")
|
| 48 |
-
gr.Markdown(" 1->512 / 2->320
|
| 49 |
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
|
@@ -80,6 +109,19 @@ def create_demo(
|
|
| 80 |
inputs=inputs,
|
| 81 |
outputs=[output_image, download_btn],
|
| 82 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
return demo
|
| 85 |
|
|
|
|
| 13 |
# limitations under the License.
|
| 14 |
|
| 15 |
import dataclasses
|
| 16 |
+
import json
|
| 17 |
+
from pathlib import Path
|
| 18 |
|
| 19 |
import gradio as gr
|
| 20 |
import torch
|
|
|
|
| 22 |
|
| 23 |
from uno.flux.pipeline import UNOPipeline
|
| 24 |
|
| 25 |
+
def get_examples(examples_dir: str = "assets/examples") -> list:
|
| 26 |
+
examples = Path(examples_dir)
|
| 27 |
+
ans = []
|
| 28 |
+
for example in examples.iterdir():
|
| 29 |
+
if not example.is_dir():
|
| 30 |
+
continue
|
| 31 |
+
with open(example / "config.json") as f:
|
| 32 |
+
example_dict = json.load(f)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
example_list = []
|
| 36 |
+
|
| 37 |
+
example_list.append(example_dict["useage"]) # case for
|
| 38 |
+
example_list.append(example_dict["prompt"]) # prompt
|
| 39 |
+
|
| 40 |
+
for key in ["image_ref1", "image_ref2", "image_ref3", "image_ref4"]:
|
| 41 |
+
if key in example_dict:
|
| 42 |
+
example_list.append(str(example / example_dict[key]))
|
| 43 |
+
else:
|
| 44 |
+
example_list.append(None)
|
| 45 |
+
|
| 46 |
+
example_list.append(example_dict["seed"])
|
| 47 |
+
example_list.append(example_dict["ref_long_side"])
|
| 48 |
+
|
| 49 |
+
ans.append(example_list)
|
| 50 |
+
return ans
|
| 51 |
+
|
| 52 |
|
| 53 |
def create_demo(
|
| 54 |
model_type: str,
|
|
|
|
| 74 |
ref_long_side = gr.Slider(128, 512, 512, step=16, label="Long side of Ref Images")
|
| 75 |
with gr.Column():
|
| 76 |
gr.Markdown("📌 **The recommended ref scale** is related to the ref img number.\n")
|
| 77 |
+
gr.Markdown(" 1->512 / 2,3,4->320")
|
| 78 |
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column():
|
|
|
|
| 109 |
inputs=inputs,
|
| 110 |
outputs=[output_image, download_btn],
|
| 111 |
)
|
| 112 |
+
|
| 113 |
+
example_text = gr.Text("", visible=False, label="Case For:")
|
| 114 |
+
examples = get_examples("./assets/examples")
|
| 115 |
+
|
| 116 |
+
gr.Examples(
|
| 117 |
+
examples=examples,
|
| 118 |
+
inputs=[
|
| 119 |
+
example_text, prompt,
|
| 120 |
+
image_prompt1, image_prompt2, image_prompt3, image_prompt4,
|
| 121 |
+
seed, ref_long_side
|
| 122 |
+
],
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
|
| 126 |
return demo
|
| 127 |
|
assets/examples/1one2one/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "A clock on the beach is under a red sun umbrella",
|
| 3 |
+
"seed": 0,
|
| 4 |
+
"ref_long_side": 512,
|
| 5 |
+
"useage": "one2one",
|
| 6 |
+
"image_ref1": "./ref1.jpg",
|
| 7 |
+
"image_result": "./result.png"
|
| 8 |
+
}
|
assets/examples/1one2one/ref1.jpg
ADDED
|
Git LFS Details
|
assets/examples/1one2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/2one2one/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "A pretty woman wears a flower petal dress, in the flower",
|
| 3 |
+
"seed": 1,
|
| 4 |
+
"ref_long_side": 512,
|
| 5 |
+
"useage": "one2one",
|
| 6 |
+
"image_ref1": "./ref1.png",
|
| 7 |
+
"image_result": "./result.png"
|
| 8 |
+
}
|
assets/examples/2one2one/ref1.png
ADDED
|
Git LFS Details
|
assets/examples/2one2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/3one2one/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "3d cartoon style, a woman.",
|
| 3 |
+
"seed": 2,
|
| 4 |
+
"ref_long_side": 512,
|
| 5 |
+
"useage": "one2one",
|
| 6 |
+
"image_ref1": "./ref1.png",
|
| 7 |
+
"image_result": "./result.png"
|
| 8 |
+
}
|
assets/examples/3one2one/ref1.png
ADDED
|
Git LFS Details
|
assets/examples/3one2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/4two2one/config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "The logo is printed on the cup",
|
| 3 |
+
"seed": 0,
|
| 4 |
+
"ref_long_side": 320,
|
| 5 |
+
"useage": "two2one",
|
| 6 |
+
"image_ref1": "./ref1.png",
|
| 7 |
+
"image_ref2": "./ref2.png",
|
| 8 |
+
"image_result": "./result.png"
|
| 9 |
+
}
|
assets/examples/4two2one/ref1.png
ADDED
|
Git LFS Details
|
assets/examples/4two2one/ref2.png
ADDED
|
Git LFS Details
|
assets/examples/4two2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/5two2one/config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "The figurine is in the crystal ball",
|
| 3 |
+
"seed": 1,
|
| 4 |
+
"ref_long_side": 320,
|
| 5 |
+
"useage": "two2one",
|
| 6 |
+
"image_ref1": "./ref1.png",
|
| 7 |
+
"image_ref2": "./ref2.png",
|
| 8 |
+
"image_result": "./result.png"
|
| 9 |
+
}
|
assets/examples/5two2one/ref1.png
ADDED
|
Git LFS Details
|
assets/examples/5two2one/ref2.png
ADDED
|
Git LFS Details
|
assets/examples/5two2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/6many2one/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "A woman wears the dress and holds a bag, in the flowers.",
|
| 3 |
+
"seed": 37635012,
|
| 4 |
+
"ref_long_side": 320,
|
| 5 |
+
"useage": "many2one",
|
| 6 |
+
"image_ref1": "./ref1.png",
|
| 7 |
+
"image_ref2": "./ref2.png",
|
| 8 |
+
"image_ref3": "./ref3.png",
|
| 9 |
+
"image_result": "./result.png"
|
| 10 |
+
}
|
assets/examples/6many2one/ref1.png
ADDED
|
Git LFS Details
|
assets/examples/6many2one/ref2.png
ADDED
|
Git LFS Details
|
assets/examples/6many2one/ref3.png
ADDED
|
Git LFS Details
|
assets/examples/6many2one/result.png
ADDED
|
Git LFS Details
|
assets/examples/7t2i/config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"prompt": "A woman wears the dress and holds a bag, in the flowers.",
|
| 3 |
+
"seed": 37635012,
|
| 4 |
+
"ref_long_side": 512,
|
| 5 |
+
"useage": "t2i",
|
| 6 |
+
"image_result": "./result.png"
|
| 7 |
+
}
|
assets/examples/7t2i/result.png
ADDED
|
Git LFS Details
|
requirements.txt
CHANGED
|
@@ -5,6 +5,5 @@ diffusers==0.30.1
|
|
| 5 |
sentencepiece==0.2.0
|
| 6 |
gradio==5.22.0
|
| 7 |
|
| 8 |
-
--extra-index-url https://download.pytorch.org/whl/cu124
|
| 9 |
torch==2.4.0
|
| 10 |
torchvision==0.19.0
|
|
|
|
| 5 |
sentencepiece==0.2.0
|
| 6 |
gradio==5.22.0
|
| 7 |
|
|
|
|
| 8 |
torch==2.4.0
|
| 9 |
torchvision==0.19.0
|