DRL_Demo / app.py
JHao2830's picture
Upload app.py
ee0152f
raw
history blame
1.78 kB
# A3C++ a modified version of Asynchronous Advantage actor critic algorithm
# -----------------------------------
#
# A3C paper: https://arxiv.org/abs/1602.01783
#
# The A3C implementation is available at:
# https://jaromiru.com/2017/02/16/lets-make-an-a3c-theory/
# by: Jaromir Janisch, 2017
# Two variations are implemented: A memory replay and a deterministic search following argmax(pi) instead of pi as a probability distribution
# Every action selection is made following the action with the highest probability pi
# Author: Taha Nakabi
# Args: 'train' for training the model anything else will skip the training and try to use already saved models
import tensorflow as tf
import numpy as np
import gym, time, random, threading
from keras.callbacks import TensorBoard
from keras.models import *
from keras.layers import *
from keras import backend as K
from tcl_env_dqn_1 import *
print("after import")
import os
import gradio as gr
from gradio.components import *
import subprocess
def main(use_default, file):
# if __name__ == '__main__':
# subprocess.run(['python', './A3C_plusplus.py'])
base = './RESULT/'
img_path = []
for i in range(1, 11):
img_path.append(base + 'DAY' + str(i) + '.png')
# else:
# 根据上传的文件执行相应的逻辑
# 请根据您的实际需求自行编写代码
return [img for img in img_path]
# 创建一个复选框来表示是否选择默认文件
default_checkbox = gr.inputs.Checkbox(label="使用默认文件", default=False)
inputs = [
default_checkbox,
File(label="上传文件", optional=True)
]
outputs = [
Image(label="DAY" + str(day + 1), type='filepath') for day in range(10)
]
iface = gr.Interface(fn=main, inputs=inputs, outputs=outputs)
iface.launch()