Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# A3C++ a modified version of Asynchronous Advantage actor critic algorithm
|
2 |
+
# -----------------------------------
|
3 |
+
#
|
4 |
+
# A3C paper: https://arxiv.org/abs/1602.01783
|
5 |
+
#
|
6 |
+
# The A3C implementation is available at:
|
7 |
+
# https://jaromiru.com/2017/02/16/lets-make-an-a3c-theory/
|
8 |
+
# by: Jaromir Janisch, 2017
|
9 |
+
|
10 |
+
# Two variations are implemented: A memory replay and a deterministic search following argmax(pi) instead of pi as a probability distribution
|
11 |
+
# Every action selection is made following the action with the highest probability pi
|
12 |
+
|
13 |
+
# Author: Taha Nakabi
|
14 |
+
|
15 |
+
# Args: 'train' for training the model anything else will skip the training and try to use already saved models
|
16 |
+
|
17 |
+
import tensorflow as tf
|
18 |
+
import numpy as np
|
19 |
+
import gym, time, random, threading
|
20 |
+
from keras.callbacks import TensorBoard
|
21 |
+
from keras.models import *
|
22 |
+
from keras.layers import *
|
23 |
+
from keras import backend as K
|
24 |
+
|
25 |
+
from tcl_env_dqn_1 import *
|
26 |
+
print("after import")
|
27 |
+
import os
|
28 |
+
import gradio as gr
|
29 |
+
from gradio.components import *
|
30 |
+
|
31 |
+
import subprocess
|
32 |
+
|
33 |
+
def main(use_default, file):
|
34 |
+
# if __name__ == '__main__':
|
35 |
+
|
36 |
+
|
37 |
+
# subprocess.run(['python', './A3C_plusplus.py'])
|
38 |
+
|
39 |
+
base = './RESULT/'
|
40 |
+
img_path = []
|
41 |
+
for i in range(1, 11):
|
42 |
+
img_path.append(base + 'DAY' + str(i) + '.png')
|
43 |
+
# else:
|
44 |
+
# 根据上传的文件执行相应的逻辑
|
45 |
+
# 请根据您的实际需求自行编写代码
|
46 |
+
|
47 |
+
return [img for img in img_path]
|
48 |
+
|
49 |
+
# 创建一个复选框来表示是否选择默认文件
|
50 |
+
default_checkbox = gr.inputs.Checkbox(label="使用默认文件", default=False)
|
51 |
+
|
52 |
+
inputs = [
|
53 |
+
default_checkbox,
|
54 |
+
File(label="上传文件", optional=True)
|
55 |
+
]
|
56 |
+
outputs = [
|
57 |
+
Image(label="DAY" + str(day + 1), type='filepath') for day in range(10)
|
58 |
+
]
|
59 |
+
|
60 |
+
iface = gr.Interface(fn=main, inputs=inputs, outputs=outputs)
|
61 |
+
|
62 |
+
iface.launch()
|
63 |
+
|
64 |
+
|
65 |
+
|