import gradio as gr import os from PIL import Image root = "/mnt/ve_share/generation/data/result/diffusions/vis/instructpix2pix/official" log_path = "/mnt/ve_share/generation/recordx.txt" def feedback(feedback_text, model, scene): output = "%s@%s@%s@%s" % (model, scene, feedback_text, length) with open(log_path, "a") as input_file: input_file.writelines(output + "\n") print(output) def get_file_paths(folder_path): file_paths = [] for root, dirs, files in os.walk(folder_path): for file in files: file_path = os.path.join(root, file) file_paths.append(file_path) return file_paths def generation_eval(): # print("request.headers: ", request.headers) models = [f for f in os.listdir(root) if os.path.isdir(os.path.join(root, f))] model_root = "%s/%s" % (root, models[-2]) scenes = [f for f in os.listdir(model_root) if os.path.isdir(os.path.join(model_root, f))] def clip_api(model, scene): # global feedback_btn # feedback_btn = gr.Radio.update(choices=['未知(反馈可持续优化LSU🤗)', '准确率低(<30%)', '准确率中(30% ~ 80%)', '准确率高(>80%)',], value='未知(反馈可持续优化LSU🤗)') ret_imgs = get_file_paths("%s/%s/%s" % (root, model, scene)) # print(ret_imgs) global length length = len(ret_imgs) ret_imgs = [Image.open(_) for _ in ret_imgs] return ret_imgs examples = [] # examples = [ # ["道路上工作的环卫工人", 20, VLP, "是"], # ["雨天打伞的人", 20, VLP, "是"], # ["救护车", 20, VLP, "是"], # ["校车", 20, VLP, "是"], # ["警车", 20, VLP, "是"], # ["喝水的人", 20, VLP, "是"], # ["后备箱打开", 20, VLP, "是"], # ] title = "