diff --git a/.DS_Store b/.DS_Store index baec9d27c833adc893defb9b28fc452512a33b26..e6f5e7034d6775317445e189de9a5c05cd29a9ba 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/MetaAugment/.DS_Store b/MetaAugment/.DS_Store index a48940a7b5f1285196b9a33f1f3f865b9ff7c9e3..51dae9e39fbd6258bc399e1b0eaf45c1f48a6c61 100644 Binary files a/MetaAugment/.DS_Store and b/MetaAugment/.DS_Store differ diff --git a/MetaAugment/UCB1_JC_py.py b/MetaAugment/UCB1_JC_py.py index 66bacb32e8896f486422bd4661c4c1f5699589ce..252a2551a68b3a0494736ec14c242e21960a6bb4 100644 --- a/MetaAugment/UCB1_JC_py.py +++ b/MetaAugment/UCB1_JC_py.py @@ -252,9 +252,6 @@ def run_UCB1(policies, batch_size, learning_rate, ds, toy_size, max_epochs, earl len_train = int(0.8*len(dataset)) train_dataset, test_dataset = torch.utils.data.random_split(dataset, [len_train, len(dataset)-len_train]) - print('train_dataset', len(train_dataset), 'test_dataset', len(test_dataset)) - - # check sizes of images img_height = len(train_dataset[0][0][0]) img_width = len(train_dataset[0][0][0][0]) @@ -335,7 +332,7 @@ def run_UCB1(policies, batch_size, learning_rate, ds, toy_size, max_epochs, earl best_q_value = max(q_values) best_q_values.append(best_q_value) - if (policy+1) % 1 == 0: + if (policy+1) % 5 == 0: print("Iteration: {},\tQ-Values: {}, Best Policy: {}".format(policy+1, list(np.around(np.array(q_values),2)), max(list(np.around(np.array(q_values),2))))) # update counts @@ -347,6 +344,7 @@ def run_UCB1(policies, batch_size, learning_rate, ds, toy_size, max_epochs, earl for i in range(num_policies): q_plus_cnt[i] = q_values[i] + np.sqrt(2*np.log(total_count)/cnts[i]) + # yield q_values, best_q_values return q_values, best_q_values diff --git a/MetaAugment/child_networks/assessment (13).pdf b/MetaAugment/child_networks/assessment (13).pdf deleted file mode 100644 index b03eef50c54bdce4130b92a7acbb4f8ad1cf7ba7..0000000000000000000000000000000000000000 Binary files a/MetaAugment/child_networks/assessment (13).pdf and /dev/null differ diff --git a/app.py b/app.py index 7ce0ae47eee0afa3e6d978ae7e59557407d6af1a..e7f2352e42c9df32fed17eb90b7002fee345ca72 100644 --- a/app.py +++ b/app.py @@ -19,6 +19,5 @@ port = int(os.environ.get("PORT", 5000)) - if __name__ == '__main__': app.run(debug=True) \ No newline at end of file diff --git a/auto_augmentation/progress.py b/auto_augmentation/progress.py index c6fa0081a0b0457a41849affe51e984a0c45e1a7..a641964994eee434f497fcb131e84922cca9aad5 100644 --- a/auto_augmentation/progress.py +++ b/auto_augmentation/progress.py @@ -39,7 +39,7 @@ def response(): early_stop_num = 10 # max number of worse validation scores before early stopping is triggered num_policies = 5 # fix number of policies num_sub_policies = 5 # fix number of sub-policies in a policy - iterations = 10 # total iterations, should be more than the number of policies + iterations = 5 # total iterations, should be more than the number of policies IsLeNet = request.form.get("network_selection") # using LeNet or EasyNet or SimpleNet ->> default print(f'@@@@@ dataset is: {ds}, network is :{IsLeNet}') @@ -66,6 +66,11 @@ def response(): # generate random policies at start policies = UCB1_JC.generate_policies(num_policies, num_sub_policies) q_values, best_q_values = UCB1_JC.run_UCB1(policies, batch_size, learning_rate, ds, toy_size, max_epochs, early_stop_num, iterations, IsLeNet, ds_name) + print("q_values: ", q_values) + + plt.figure() + plt.plot(q_values) + plt.savefig('/static/image/test.png') # plt.plot(best_q_values) diff --git a/auto_augmentation/templates/basic.html b/auto_augmentation/templates/basic.html index db609ea5f49ca101d3394b2e1219c1488160908b..9c47ba6a00c5cf9920c4f3f96f8810b2bd530018 100644 --- a/auto_augmentation/templates/basic.html +++ b/auto_augmentation/templates/basic.html @@ -1,5 +1,18 @@ <!doctype html> <html> + <style> + #myProgress { + width: 100%; + background-color: #ddd; + } + + #myBar { + width: 1%; + height: 30px; + background-color: #04AA6D; + } + </style> + <head> {% block head %} <title>{% block title %}{% endblock %} - Meta Reinforcement Learning for Data Augmentation</title> diff --git a/auto_augmentation/templates/home.html b/auto_augmentation/templates/home.html index 010cdfd89c7e2681926467af0f2444cd922c9992..4e423f21ad6d36df55cf1d9b7c58b3e7466da8de 100644 --- a/auto_augmentation/templates/home.html +++ b/auto_augmentation/templates/home.html @@ -129,32 +129,105 @@ <label for="Invert">Invert</label><br><br><br> - <!-- <div id="exclude_augments" class="dropdown-check-list" tabindex="100"> - <span class="anchor">Select data augmentation method(s) to exclude:</span> - <ul class="items"> - <input type="checkbox" />Translate - <input type="checkbox" />Rotate - <input type="checkbox" />AutoContrast - <input type="checkbox" />Equalize - <br> - <input type="checkbox" />Solarize - <input type="checkbox" />Posterize - <input type="checkbox" />Contrast - <input type="checkbox" />Brightness - </ul> - </div> --> - - <div id="exclude_augments"> - <span class="anchor">Hyperparameter (Learning Rate):</span> - <ul class="items"> - Automatic: <input type="checkbox" /> <div></div> - Manual: <input type="number" /> - </ul> - </div> - + <div id="like_button_container"></div> + <script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script> + + <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script> + <!-- <script src="metarl/auto_augmentation/templates/like_button.js"></script> --> + + <script type = 'module'> + // 'use strict'; + import React from 'react'; + import ReactDOM from 'react-dom'; + + </script> + + + <script> + const e = React.createElement; + + class LikeButton extends React.Component { + constructor(props) { + super(props); + this.state = { liked: false }; + } + + render() { + if (this.state.liked) { + return 'You liked this.'; + } + + return e( + 'button', + { onClick: () => this.setState({ liked: true }) }, + 'Like' + ); + } + } + + + const domContainer = document.querySelector('#like_button_container'); + const root = ReactDOM.createRoot(domContainer); + root.render(e(LikeButton)); + </script> + + + + + + + + + <!-- 3 + <div id="mydiv"></div> + + <script type="text/babel" type="javascript"> + import ReactDOM from 'react-dom'; + function Hello() { + return <h1>Hello World!</h1>; + } + + ReactDOM.render(<Hello />, document.getElementById('mydiv')) + </script> + 3 --> + + + <!-- ----------------- --> + + + <!-- <script + src="https://unpkg.com/react@16/umd/react.production.min.js" + crossorigin + type="javascript" + ></script> + <script + src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" + crossorigin + ></script> + <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> + + <script type="text/babel" src="WelcomeBack.js"></script> + <script type="text/babel" src="CoolButton.js"></script> + + <script type="text/babel"> + ReactDOM.render(<WelcomeBack />, document.querySelector(".welcome-back")); + </script> --> + + + + + + + + + + <input type="submit"> + + </form> - + + {% endblock %} diff --git a/auto_augmentation/templates/like_button.js b/auto_augmentation/templates/like_button.js new file mode 100644 index 0000000000000000000000000000000000000000..2e45150f6e4c1c2752910065dd4cc9c1e29fc9ca --- /dev/null +++ b/auto_augmentation/templates/like_button.js @@ -0,0 +1,29 @@ +'use strict'; + import React from 'react'; + import ReactDOM from 'react-dom'; + +const e = React.createElement; +console.log('hello') +class LikeButton extends React.Component { + constructor(props) { + super(props); + this.state = { liked: false }; + } + + render() { + if (this.state.liked) { + return <p>'You liked this.'</p>; + } + + return e( + 'button', + { onClick: () => this.setState({ liked: true }) }, + 'Like' + ); + } +} + + +const domContainer = document.querySelector('#like_button_container'); +const root = ReactDOM.createRoot(domContainer); +root.render(e(LikeButton)); \ No newline at end of file diff --git a/auto_augmentation/templates/progress.html b/auto_augmentation/templates/progress.html index ea4c33d713224bd889f147ddcb5f8d2e6fb0b6f7..7228b06b1c398e6d55b5472b47dd0db2d304bea8 100644 --- a/auto_augmentation/templates/progress.html +++ b/auto_augmentation/templates/progress.html @@ -5,10 +5,39 @@ Training the model... <div> <img src="{{url_for('static', filename='image/training_plot.png')}}" class="img-thumbnail" /> + + + <div id="myProgress"> + <div id="myBar"></div> + </div> + + <br> + <button onclick="move()">Click Me</button> + + <script> + var i = 0; + function move() { + if (i == 0) { + i = 1; + var elem = document.getElementById("myBar"); + var width = 1; + var id = setInterval(frame, 10); + function frame() { + if (width >= 100) { + clearInterval(id); + i = 0; + } else { + width++; + elem.style.width = width + "%"; + } + } + } + } + </script> + <form action="/show_result"> <input type="submit" value='Show Result'> </form> - </div> {% endblock %} \ No newline at end of file