File size: 1,846 Bytes
c34ed4d
 
 
 
 
 
0a8f9dd
c34ed4d
0a8f9dd
c34ed4d
 
 
 
 
 
0a8f9dd
c34ed4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a8f9dd
c34ed4d
0a8f9dd
 
 
c34ed4d
83190e8
c34ed4d
0a8f9dd
c34ed4d
0a8f9dd
 
 
 
 
 
 
 
c34ed4d
 
 
0a8f9dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import cv2
import numpy as np
import streamlit as st
import os
import base64

st.set_page_config(layout="wide", page_title="CoNR demo", page_icon="🪐")

st.title("CoNR demo")
st.markdown(""" <style> 
            #MainMenu {visibility: hidden;} 
            footer {visibility: hidden;} 
            </style> """, unsafe_allow_html=True)

def get_base64(bin_file):
    with open(bin_file, "rb") as f:
        data = f.read()
    return base64.b64encode(data).decode()

# def set_background(png_file):
#     bin_str = get_base64(png_file)
#     page_bg_img = '''
#     <style>
#     .stApp {
#     background-image: url("data:image/png;base64,%s");
#     background-size: 1920px 1080px;
#     background-attachment:fixed;
#     background-position:center;
#     background-repeat:no-repeat;
#     }
#     </style>
#     ''' % bin_str
#     st.markdown(page_bg_img, unsafe_allow_html=True)

# set_background('ipad_bg.png')

upload_img = (st.file_uploader("输入character sheet", "png", accept_multiple_files=True))
upload_img2 = (st.file_uploader("pose images", "png", accept_multiple_files=True))

# os.system("sh download.sh")

if st.button("RUN!"):
    if upload_img is not None:
        os.makedirs("character_sheet", exist_ok=True)
        for i in range(len(upload_img)):
            with open("character_sheet/{}.png".format(i), "wb") as f:
                f.write(upload_img[i].read())
        os.makedirs("poses", exist_ok=True)
        for i, e in enumerate(upload_img2):
            with open(f"poses/{i}.png", "wb") as f:
                f.write(e.read())
        st.info("努力推理中...")
        os.system("sh infer.sh")
        st.info("Done!")
        video_file=open("output.mp4", "rb")
        video_bytes = video_file.read()
        st.video(video_bytes, start_time=0)
    else:
        st.info("还没上传图片呢> <")