Spaces:
Runtime error
Runtime error
neverix
commited on
Commit
•
c965522
1
Parent(s):
7e80faa
Backwards compatible gradIO
Browse files- .gitattributes +2 -0
- .gitignore +3 -2
- README.md +2 -2
- app.py +40 -50
- character_sheet_ponytail_example/0.png +3 -0
- character_sheet_ponytail_example/1.png +3 -0
- character_sheet_ponytail_example/2.png +3 -0
- character_sheet_ponytail_example/3.png +3 -0
- images/MAIN.png +0 -0
- poses.zip +3 -0
.gitattributes
CHANGED
@@ -29,3 +29,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
33 |
+
poses.zip filter=lfs diff=lfs merge=lfs -text
|
.gitignore
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
results/
|
|
|
2 |
test_data/
|
3 |
test_data_pre/
|
4 |
character_sheet/
|
5 |
# weights/
|
6 |
-
x264/
|
7 |
-
*.mp3
|
8 |
*.mp4
|
|
|
|
|
9 |
filelist.txt
|
10 |
complex_infer.sh
|
11 |
__pycache__/
|
|
|
1 |
results/
|
2 |
+
poses/
|
3 |
test_data/
|
4 |
test_data_pre/
|
5 |
character_sheet/
|
6 |
# weights/
|
|
|
|
|
7 |
*.mp4
|
8 |
+
*.webm
|
9 |
+
x264/
|
10 |
filelist.txt
|
11 |
complex_infer.sh
|
12 |
__pycache__/
|
README.md
CHANGED
@@ -3,8 +3,8 @@ title: CoNR
|
|
3 |
emoji: ⚡
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
-
sdk:
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
3 |
emoji: ⚡
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.14.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -1,63 +1,53 @@
|
|
1 |
-
import cv2
|
2 |
import numpy as np
|
3 |
-
import
|
4 |
import os
|
5 |
import base64
|
6 |
|
7 |
-
st.set_page_config(layout="wide", page_title="CoNR demo", page_icon="🪐")
|
8 |
-
|
9 |
-
st.title("CoNR demo")
|
10 |
-
st.markdown(""" <style>
|
11 |
-
#MainMenu {visibility: hidden;}
|
12 |
-
footer {visibility: hidden;}
|
13 |
-
</style> """, unsafe_allow_html=True)
|
14 |
|
15 |
def get_base64(bin_file):
|
16 |
with open(bin_file, "rb") as f:
|
17 |
data = f.read()
|
18 |
return base64.b64encode(data).decode()
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
# page_bg_img = '''
|
23 |
-
# <style>
|
24 |
-
# .stApp {
|
25 |
-
# background-image: url("data:image/png;base64,%s");
|
26 |
-
# background-size: 1920px 1080px;
|
27 |
-
# background-attachment:fixed;
|
28 |
-
# background-position:center;
|
29 |
-
# background-repeat:no-repeat;
|
30 |
-
# }
|
31 |
-
# </style>
|
32 |
-
# ''' % bin_str
|
33 |
-
# st.markdown(page_bg_img, unsafe_allow_html=True)
|
34 |
-
|
35 |
-
# set_background('ipad_bg.png')
|
36 |
-
|
37 |
-
upload_img = (st.file_uploader("输入character sheet", "png", accept_multiple_files=True))
|
38 |
-
pose_format = "png"
|
39 |
-
upload_img2 = (st.file_uploader("pose images", pose_format, accept_multiple_files=True))
|
40 |
-
|
41 |
-
# os.system("sh download.sh")
|
42 |
-
|
43 |
-
if st.button("RUN!"):
|
44 |
os.system("rm character_sheet/*")
|
45 |
os.system("rm result/*")
|
46 |
os.system("rm poses/*")
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import numpy as np
|
2 |
+
import gradio as gr
|
3 |
import os
|
4 |
import base64
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
def get_base64(bin_file):
|
8 |
with open(bin_file, "rb") as f:
|
9 |
data = f.read()
|
10 |
return base64.b64encode(data).decode()
|
11 |
|
12 |
+
|
13 |
+
def conr_fn(character_sheets, pose_zip):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
os.system("rm character_sheet/*")
|
15 |
os.system("rm result/*")
|
16 |
os.system("rm poses/*")
|
17 |
+
os.makedirs("character_sheet", exist_ok=True)
|
18 |
+
for i, e in enumerate(character_sheets):
|
19 |
+
with open(f"character_sheet/{i}.png", "wb") as f:
|
20 |
+
e.seek(0)
|
21 |
+
f.write(e.read())
|
22 |
+
e.seek(0)
|
23 |
+
os.makedirs("poses", exist_ok=True)
|
24 |
+
pose_zip.seek(0)
|
25 |
+
open("poses.zip", "wb").write(pose_zip.read())
|
26 |
+
os.system(f"unzip -d poses poses.zip")
|
27 |
+
os.system("sh infer.sh")
|
28 |
+
return "output.mp4"
|
29 |
+
|
30 |
+
|
31 |
+
with gr.Blocks() as ui:
|
32 |
+
gr.Markdown("CoNR demo")
|
33 |
+
gr.Markdown("<a target='_blank' href='https://colab.research.google.com/github/megvii-research/CoNR/blob/main/notebooks/conr.ipynb'> <img src='https://colab.research.google.com/assets/colab-badge.svg' alt='Open In Colab'/></a>")
|
34 |
+
gr.Markdown("Unofficial demo for CoNR.")
|
35 |
+
|
36 |
+
with gr.Row():
|
37 |
+
with gr.Column():
|
38 |
+
gr.Markdown("## Parse video")
|
39 |
+
with gr.Column():
|
40 |
+
gr.Markdown("## Animate character")
|
41 |
+
gr.Markdown("Character sheet")
|
42 |
+
character_sheets = gr.File(file_count="multiple")
|
43 |
+
gr.Markdown("Pose zip") # Don't hack
|
44 |
+
pose_video = gr.File(file_count="single")
|
45 |
+
|
46 |
+
# os.system("sh download.sh")
|
47 |
+
run = gr.Button("Run")
|
48 |
+
video = gr.Video()
|
49 |
+
run.click(fn=conr_fn, inputs=[character_sheets, pose_video], outputs=video)
|
50 |
+
|
51 |
+
# ui.launch()
|
52 |
+
demo = ui
|
53 |
+
demo.launch()
|
character_sheet_ponytail_example/0.png
ADDED
Git LFS Details
|
character_sheet_ponytail_example/1.png
ADDED
Git LFS Details
|
character_sheet_ponytail_example/2.png
ADDED
Git LFS Details
|
character_sheet_ponytail_example/3.png
ADDED
Git LFS Details
|
images/MAIN.png
CHANGED
Git LFS Details
|
poses.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0d6a3ed9527dd6b04275bf4c81704ac50c9b8cd1bf4a26b1d3ec6658e200ff57
|
3 |
+
size 10662874
|