| # 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 gradio as gr | |
| from gradio.components import * | |
| import subprocess | |
| def main(use_default, file): | |
| 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() | |