Skip to content

Instantly share code, notes, and snippets.

View jmlb's full-sized avatar

Jean-Marc Beaujour jmlb

View GitHub Profile
"""
from to https://towardsdatascience.com/how-to-scale-training-on-multiple-gpus-dae1041f49d2
"""
import os
from datetime import datetime
import argparse
import torch.multiprocessing as mp
import torchvision
import torchvision.transforms as transforms
import torch
from evdev import InputDevice, categorize, ecodes
from select import select
import Adafruit_PCA9685
dev = InputDevice('/dev/input/event0') #event0 is the name of the bluetooth dongle
pwm = Adafruit_PCA9685.PCA9685() # RPi servo hat library
pwm.set_pwm_freq(50)
#Joystick value are in range [0, 255]
joystick_value = 128 #idle mode
plot_flag = 0
function plot(elt){
Plotly.purge("graph")
if (plot_flag == 1){
clearInterval(interval)
}
.......
<html>
<head>
<script src="js/plotly-latest.min.js"></script>
<script>
function rand() {
return Math.random();
}
// plot_cnt tells if function plot has been ran or not
<script>
myplot = document.getElementById('show_plot');
Plotly.plot( myplot, [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16] }], {
margin: { t:0 } } );
</script>
<div id="show_plot" style="width:600px; height:250px;"> </div>
<header>
<script type="text/javascript" src="https://cdn.plot.ly/plotly-latest.min.js">
</script>
</header>
from plotly.offline import init_notebook_mode, iplot
from plotly.graph_objs import *
init_notebook_mode()
trace1 = Bar(
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
y = [13, 13.2, 11.3, 12, 8.4, 9, 9.5, 6.5, 6.8, 4.3, 3.2, 2.8, 1.1, 0]
)
data = [trace1]
from plotly.offline import init_notebook_mode, iplot
from plotly.graph_objs import *
init_notebook_mode()
trace0 = Scatter(
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
y = [13, 13.2, 11.3, 12, 8.4, 9, 9.5, 6.5, 6.8, 4.3, 3.2, 2.8, 1.1, 0]
)
trace1 = Scatter(
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
from plotly.offline import init_notebook_mode, iplot
from plotly.graph_objs import *
init_notebook_mode()
#Generate some data
data_x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
data_y = [13, 13.2, 11.3, 12, 8.4, 9, 9.5, 6.5, 6.8, 4.3, 3.2, 2.8, 1.1, 0]
iplot([Scatter(x=data_x, y=data_y)])