예제 #1
0
def CreateVectorDemo():
    graph = vi.IPGraph("Image-6")
    graph.SetFrameColor(vi.PFillType.FillType_Solid,
                        [vi.MakeColor(200, 200, 200)])
    graph.SetPlotAreaColor(vi.PFillType.FillType_Solid,
                           [vi.MakeColor(255, 255, 255)])

    #xaxis
    xaxis = graph.Axes(0)
    xaxis.SetMinimum(-10)
    xaxis.SetMaximum(10)
    xaxis.SetTitle("X")
    xaxis.ModifyOption(vi.PAxisOptions.MajorGrid, False)
    #yaxis
    yaxis = graph.Axes(1)
    yaxis.SetMinimum(-10)
    yaxis.SetMaximum(10)
    yaxis.SetTitle("Y")
    graph.SetMouseTrackingMode(
        vi.PGraphMouseTrackingMode.TrackingMode_ZoomX
        | vi.PGraphMouseTrackingMode.TrackingMode_PanX, True)

    #vector plot
    plotnum = graph.GetPlotCount()
    for i in range(plotnum):
        graph.RemovePlot(0)
    vector1 = graph.NewPlot("vect1")
    vector1.SetPlotStyle(vi.PPlotStyle.XYVector)
예제 #2
0
def PlotChartAnimation(bool1, chartname1, bool2, chartname2, chartDir):
    global phase
    global chartNum
    global phase2

    if (bool1 == True):
        graph = vi.IPGraph(chartname1)
        #make sine graph
        i = 0
        x = phase * np.pi / 180
        dx = 2 * np.pi * freq
        while i < 200:
            datay1[i] = np.sin(x)
            x = x + dx
            i = i + 1
        x = phase + freq * 360 * i
        phase = x - (x / 360) * 360
        plot = graph.Plots(0)
        plot.PlotXRange(0, 1)
        plot.PlotZRange(0.0, 0.0)
        plot.PlotY(datay1)
        plot1 = graph.Plots(1)
        plot1.PlotXRange(0, 1)
        plot1.PlotYRange(0.0, 0.0)
        plot1.PlotZ(datay1)
        plot2 = graph.Plots(2)
        for j in range(4000):
            datay[j] = np.fabs(datay1[(int(j / 20))]) * np.sin(j * np.pi / 10)
            dataz[j] = np.fabs(datay1[(int(j / 20))]) * np.cos(j * np.pi / 10)
        plot2.PlotXRange(0, 1 / 20.0)
        plot2.PlotY(datay)
        plot2.PlotZ(dataz)

    if (bool2 == True):
        graph2 = vi.IPGraph(chartname2)
        #make sine graph
        j = 0
        x2 = phase2 * np.pi / 180
        dx2 = 2 * np.pi * freq
        while j < 2:
            y[j] = np.sin(x2)
            x2 = x2 + dx2
            j = j + 1
        x2 = phase2 + freq * 360 * j
        phase2 = x2 - (int(x2 / 360)) * 360
        chart = graph2.Plots(0)
        chart1 = graph2.Plots(1)
        chart2 = graph2.Plots(2)
        chart.PlotZRange(0.0, 0.0)
        chart1.PlotYRange(0.0, 0.0)
        if (chartDir == 0):
            chart.ChartY(y)
            chart1.ChartZ(y)
        for i in range(20):
            datay2[i] = np.fabs(y[(int(i / 10))]) * np.sin(i * np.pi / 10)
            dataz2[i] = np.fabs(y[(int(i / 10))]) * np.cos(i * np.pi / 10)
            datax2[i] = chartNum + 1 / 20.0
        chart2.ChartXYZ(datax2, datay2, dataz2)
예제 #3
0
def MakeCursor( graphname, name, xpos=50, ypos=5, color = vi.MakeColor(255,0,0), style = vi.CursorLineShape.CursorMajorXMajorY, snap = vi.GraphObjSnapModes.SnapFloating):
    graph = vi.IPGraph( graphname )
    cursor = graph.NewCursor(name)
    cursor.SetColor(color)
    cursor.SetCursorStyle(style)
    cursor.SetSnapMode(snap)
    cursor.SetCursorPos(xpos,ypos)
    cursor.ModifyOption(vi.CursorOptions.CursorShowLabel, True)
    return cursor
예제 #4
0
def PlotChartAnimation( bool1, chartname1, bool2, chartname2, chartDir ):
    global phase 
    global chartNum
    
    if( bool1 == True ):
        graph = vi.IPGraph( chartname1 )
        #make sine graph
        i = 0
        x = phase * np.pi / 180
        dx = 2 * np.pi * freq
        while i < 200:
            datay1[i] = np.sin(x)
            x = x + dx
            i = i + 1
        x = phase + freq * 360 * i
        phase = x - (x / 360) * 360
        plot = graph.Plots(0)
        plot.PlotXRange( 0, 1 )
        plot.PlotZRange( 0.0, 0.0 )
        plot.PlotY( datay1 )
        plot1 = graph.Plots(1)
        plot1.PlotXRange( 0, 1 )
        plot1.PlotYRange( 0.0, 0.0 )
        plot1.PlotZ( datay1 )
        plot2 = graph.Plots(2)
        for j in range(4000):
            datay[j] = np.fabs(datay1[( int(j / 20) )]) * np.sin( j * np.pi / 10 )
            dataz[j] = np.fabs(datay1[( int(j / 20) )]) * np.cos( j * np.pi / 10 )
        plot2.PlotXRange( 0, 1 / 20.0 )
        plot2.PlotY( datay )
        plot2.PlotZ( dataz )
      
    if( bool2 == True and timercount % 5 == 0 ):
        graph = vi.IPGraph( chartname2 )
        #make sine graph
        i = 0
        x = phase * np.pi / 180
        dx = 2 * np.pi * freq
        while i < 200:
            y[i] = np.sin(x)
            x = x + dx
            i = i + 1
        x = phase + freq * 360 * i
        phase = x - (x / 360) * 360
        plot = graph.Plots(0)
        plot1 = graph.Plots(1)
        plot2 = graph.Plots(2)
        plot.PlotZRange( 0.0, 0.0 )
        plot1.PlotYRange( 0.0, 0.0 )
        if( chartDir == 0 ):
            plot.ChartY( y )
            plot1.ChartZ( y )
        for j in range(20):
            datay2[j] = np.fabs(y[( int(j / 10) )]) * np.sin( j * np.pi / 10 )
            dataz2[j] = np.fabs(y[( int(j / 10) )]) * np.cos( j * np.pi / 10 )    
            datax2[j] = chartNum + 1 / 20.0
        plot2.ChartXYZ( datax2, datay2, dataz2 )
예제 #5
0
파일: Polar.py 프로젝트: IVAI2000/AIStudio
def CreatePolar2Demo(name):
    global polarindex
    graph = vi.IPGraph(name)
    plot = graph.Plots(0)
    d = 150 * np.sin(polarindex * 2 * np.pi / 90.0) * abs(
        np.cos(polarindex * 2 * np.pi / 360.0))
    polarindex = polarindex + 1
    plot.ChartY([d])
    plot.SetLineColor(vi.MakeColor(255, 0, 0))
    plot.SetLineWidth(2)
    if (polarindex > 720):
        polarindex = 0
        plot = graph.NewPlot("PolarCurve")
        plot.ChartXRange(0, 1, 360)
예제 #6
0
파일: test.py 프로젝트: IVAI2000/AIStudio
def LoadAudioData():
    ass = iv.ShortVector(1)
    n, sr, cc = studio.LoadAudio(model_path + "\\yes.wav",  ass)
    spectrum = iv.ComplexVector(10)
    r = tranform.STFFT(ass, 128, 161, True, spectrum)
    aspectrum = studio.ToNumpy(spectrum)
    spect = np.absolute(aspectrum)
    spect = np.log1p(spect)
    spect = spect.reshape(161, -1)
    spect = torch.FloatTensor(spect)
    mean = spect.mean()
    std = spect.std()
    spect.add_(-mean)
    spect.div_(std)
    return spect
예제 #7
0
파일: test.py 프로젝트: IVAI2000/AIStudio
def GetAudioData():
    ass = iv.ShortVector(1)
    studio.GetAudioStream("Record", ass, 5.0, 16000.0, 1)
    #studio.WriteAudio("c:\\data\\test.wav", ass, 16000.0, 1)
    spectrum = iv.ComplexVector(10)
    r = tranform.STFFT(ass, 128, 161, True, spectrum)
    aspectrum = studio.ToNumpy(spectrum)
    spect = np.absolute(aspectrum)
    spect = np.log1p(spect)
    spect = spect.reshape(161, -1)
    spect = torch.FloatTensor(spect)
    mean = spect.mean()
    std = spect.std()
    spect.add_(-mean)
    spect.div_(std)
    return spect
예제 #8
0
파일: Polar.py 프로젝트: IVAI2000/AIStudio
def CreatePolarDemo():
    graph = vi.IPGraph("Image-7")
    graph.SetGraphCategory(vi.PGraphCategory.Polar, vi.PPlotStyle.PolarImage)

    #palette
    palette = graph.SetPalette(0, 1, True)

    #axis
    xaxis = graph.Axes(0)
    yaxis = graph.Axes(1)
    yaxis.SetMinimum(0)
    yaxis.SetMaximum(200)
    xaxis.ModifyOption(vi.PAxisOptions.MajorGrid, True)
    yaxis.ModifyOption(vi.PAxisOptions.MajorGrid, True)
    xaxis.SetMajorGridColor(vi.MakeColor(0, 0, 255))
    yaxis.SetMajorGridColor(vi.MakeColor(0, 0, 255))

    plotnum = graph.GetPlotCount()
    for i in range(plotnum):
        graph.RemovePlot(0)
    pImg = graph.NewPlot("PolarImage")
    pImg.SetPlotStyle(vi.PPlotStyle.PolarImage)
    pImg.ImageRange(0, 1, 0, 1)
    dataxy = np.empty(200 * 360)
    for iy in range(200):
        for ix in range(360):
            dataxy[ix + iy * 360] = np.sin(ix * 2 * np.pi / 90.0) * np.sin(
                iy / 10.0) * abs(np.cos(ix * 2 * np.pi / 360.0))
    pImg.ImageColor(dataxy, 360, 200)
    for ix in range(360):
        dataxy[ix] = 150 * np.sin(ix * 2 * np.pi / 90.0) * abs(
            np.cos(ix * 2 * np.pi / 360.0))

    plotnum = graph.GetPlotCount()
    for i in range(plotnum):
        graph.RemovePlot(1)
    plot = graph.NewPlot("PolarCurve")
    plot.SetPlotStyle(vi.PPlotStyle.PolarCurve)
    plot.PlotY(dataxy)
    plot.PlotXRange(0, 1)
    plot.SetLineColor(vi.MakeColor(0, 255, 0))
    plot.SetLineWidth(2)
    dataxy = []
예제 #9
0
def CreateBubbleDemo():
    graph = vi.IPGraph("Image-5")
    graph.SetFrameColor(vi.PFillType.FillType_Solid,
                        [vi.MakeColor(200, 200, 200)])
    graph.SetPlotAreaColor(vi.PFillType.FillType_Solid,
                           [vi.MakeColor(255, 255, 255)])

    #palette
    palette = graph.SetPalette(0, 1, True)

    #xaxis
    xaxis = graph.Axes(0)
    xaxis.SetMinimum(0)
    xaxis.SetMaximum(1)
    xaxis.SetTitle("X")
    xaxis.ModifyOption(vi.PAxisOptions.MajorGrid, False)
    #yaxis
    yaxis = graph.Axes(1)
    yaxis.SetMinimum(0)
    yaxis.SetMaximum(1)
    yaxis.SetTitle("Y")
    graph.SetMouseTrackingMode(
        vi.PGraphMouseTrackingMode.TrackingMode_ZoomX
        | vi.PGraphMouseTrackingMode.TrackingMode_PanX, True)

    #bubble plot
    plotnum = graph.GetPlotCount()
    for i in range(plotnum):
        graph.RemovePlot(0)
    bubble1 = graph.NewPlot("bubble1")
    bubble1.SetPlotStyle(vi.PPlotStyle.XYBubble)
    bubble1.SetBubblePara(20)

    #cursor
    cursorcount = graph.GetCursorCount()
    if cursorcount < 1:
        cursor = MakeCursor("Image-5", "cursor", 0.5, 0.5)
    else:
        graph.RemoveCursor("cursor")
        cursor = MakeCursor("Image-5", "cursor", 0.5, 0.5)
예제 #10
0
def BubbleVectorAnimation( bool1, bool2, bubblename, vectorname ) :
    if ( bool1 and timercount % 5 == 0 ):
        bgraph = vi.IPGraph( bubblename )
        bubble = bgraph.Plots(0)
        data1 = [random.uniform(0,1) for i in range(100)] 
        data2 = [random.uniform(0,1) for i in range(100)]
        data3 = [random.uniform(0,1) for i in range(100)]
        bubble.BubbleXY(data1, data2, data3)
    if( bool2 and timercount % 15 == 0 ):
        vgraph = vi.IPGraph( vectorname )
        vector = vgraph.Plots(0)
        vector.SetVectorPara(4, 40)
        data1 = [random.uniform(0,1) for i in range(200)] 
        data2 = [random.uniform(0,1) for i in range(200)]
        data3 = np.empty(200)
        data4 = np.empty(200)
        for i in range(200):
            data1[i] = data1[i] - 0.5
            data2[i] = data2[i] - 0.5
            data3[i] = np.arctan2( data2[i], data1[i] ) * 180 / np.pi
            data4[i] = np.sqrt( data1[i] * data1[i] + data2[i] * data2[i] ) * 2
            data1[i] = data1[i] * 20
            data2[i] = data2[i] * 20
        vector.VectorAL( data1, data2, data3, data4 )
예제 #11
0
파일: Polar.py 프로젝트: IVAI2000/AIStudio
def CreatePolarDemo2():
    graph = vi.IPGraph("Image-8")
    graph.SetPlotAreaColor(vi.PFillType.FillType_Solid,
                           [vi.MakeColor(197, 251, 196)])
    graph.SetGraphCategory(vi.PGraphCategory.Polar, vi.PPlotStyle.PolarImage)

    palette = graph.SetPalette(0, 1, False)

    #axis
    xaxis = graph.Axes(0)
    yaxis = graph.Axes(1)
    yaxis.SetMinimum(0)
    yaxis.SetMaximum(200)
    xaxis.ModifyOption(vi.PAxisOptions.MajorGrid, True)
    xaxis.SetMajorGridColor(vi.MakeColor(0, 0, 255))
    xaxis.ModifyOption(vi.PAxisOptions.ShowTitle, False)
    yaxis.SetMajorGridColor(vi.MakeColor(0, 0, 255))
    yaxis.ModifyOption(
        (vi.PAxisOptions.ShowTitle | vi.PAxisOptions.ShowTick
         | vi.PAxisOptions.TickLabel | vi.PAxisOptions.AxisLine), False)

    axisnum = graph.GetAxisCount()
    if axisnum < 3:
        axisrad = graph.NewAxis("Radius", vi.PAxisType.AxisRadius)
    else:
        axisrad = graph.Axes(2)
    axisrad.SetTickPadding(vi.PAxisOptions.FixPadding)
    axisrad.AddValuePair("E", 0, vi.MakeColor(0, 0, 255))
    axisrad.AddValuePair("N", 90, vi.MakeColor(0, 0, 255))
    axisrad.AddValuePair("W", 180, vi.MakeColor(0, 0, 255))
    axisrad.AddValuePair("S", 270, vi.MakeColor(0, 0, 255))
    axisrad.ModifyOption(vi.PAxisOptions.ValuePairOnly, True)

    plotnum = graph.GetPlotCount()
    for i in range(plotnum):
        graph.RemovePlot(0)
    plot = graph.NewPlot("PolarCurve")
    plot.SetPlotStyle(vi.PPlotStyle.PolarCurve)
    plot.ChartXRange(0, 1, 360)
예제 #12
0
파일: test.py 프로젝트: IVAI2000/AIStudio
#deep speed for pytorch
#revised based on https://github.com/SeanNaren/deepspeech.pytorch
#from https://github.com/SeanNaren/deepspeech.pytorch/releases to download pretrained model ibrispeech_pretrained.pth 

import numpy as np
from torch.autograd import Variable
import torch
from decoder import GreedyDecoder
from model import DeepSpeech
import IStudio as iv
import json

studio = iv.AIStudio("pytorch")

filename = inspect.getframeinfo(inspect.currentframe()).filename
model_path     = os.path.dirname(os.path.abspath(filename))
model_file = model_path + "\\librispeech_pretrained.pth"
cuda = "store_true"
batch_size = 20
num_workers = 4
decoder = "greedy"
verbose = "store_true"
top_paths = 1
beam_width = 10
lm_path = None
alpha = 0.8
beta = 1
cutoff_top_n = 40
cutoff_prob = 1
lm_workers = 1
예제 #13
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import sys
import tempfile

from tensorflow.examples.tutorials.mnist import input_data
from time import sleep
import tensorflow as tf
import IStudio as iv
import numpy as np
FLAGS = None
studio = iv.AIStudio("tensorflow")
print( studio.DataFolder)
np.set_printoptions(threshold=100)

def deepnn(x):
    """deepnn builds the graph for a deep net for classifying digits.

    Args:
        x: an input tensor with the dimensions (N_examples, 784), where 784 is the
        number of pixels in a standard MNIST image.

    Returns:
        A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10), with values
        equal to the logits of classifying the digit into one of 10 classes (the
        digits 0-9). keep_prob is a scalar placeholder for the probability of
        dropout.
예제 #14
0
파일: Bar.py 프로젝트: luwent/AIStudio
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random

#topgraph
graph = vi.IPGraph("Bar-1")
graph.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(200, 200, 200)])
graph.SetPlotAreaColor(vi.FillType.FillType_Solid,
                       [vi.MakeColor(255, 255, 255)])
graph.SetCaption("Temperature vs. Month")

#legend
legend = graph.GetLegend()
legend.SetVisible(True)

legend.SetLocationSide(vi.LocationSide.Location_Bottom)

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0.5)
xaxis.SetMaximum(12.5)
xaxis.SetTitle("Month")
xaxis.ModifyOption(vi.AxisOptions.MajorGrid, False)
#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(-10)
예제 #15
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random

#top graph
graph = vi.IPGraph("Chart-1")
graph.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(223, 218, 241)])
graph.SetPlotAreaColor(vi.FillType.FillType_Solid, [vi.MakeColor(255, 255, 255)])
graph.SetCaption("Chart Graph Example")

#bottom graph
graph2 = vi.IPGraph("Plot-2")
graph2.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(223, 218, 241)])
graph2.SetPlotAreaColor(vi.FillType.FillType_Solid, [vi.MakeColor(255, 255, 255)])
graph2.SetCaption("Random Plot Graph Example")

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("Time")
#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(-10)
yaxis.SetMaximum(10)
yaxis.SetTitle("Distance")
예제 #16
0
파일: Bar3D.py 프로젝트: luwent/AIStudio
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random

#topgraph
filename = inspect.getframeinfo(inspect.currentframe()).filename
file_path = os.path.dirname(os.path.abspath(filename))
graph = vi.IPGraph("Graph3D-6")
graph.SetCaption("Temperature vs. Month")
graph.SetMouseTrackingMode(vi.GraphMouseTrackingMode.TrackingMode_Rotation,
                           True)
graph.SetOrientation(-422.2, 0, -347.7)
graph.SetGraphCategory(vi.GraphCategory.Bar3D, vi.PlotStyle.BarVBar)
graph.SetSkyBackground(file_path + "\\right.jpg", file_path + "\\left.jpg",
                       file_path + "\\top.jpg", file_path + "\\bottom.jpg",
                       file_path + "\\back.jpg", file_path + "\\front.jpg")

#legend
legend = graph.GetLegend()
legend.SetVisible(True)

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0.5)
xaxis.SetMaximum(12.5)
xaxis.SetTitle("Month")
예제 #17
0
               xpos=50,
               ypos=5,
               color=vi.MakeColor(255, 0, 0),
               style=vi.CursorLineShape.CursorMajorXMajorY,
               snap=vi.GraphObjSnapModes.SnapFloating):
    cursor = graph.NewCursor(name)
    cursor.SetColor(color)
    cursor.SetCursorStyle(style)
    cursor.SetSnapMode(snap)
    cursor.SetCursorPos(xpos, ypos)
    cursor.ModifyOption(vi.CursorOptions.CursorShowLabel, True)
    return cursor


#topgraph
graph = vi.IPGraph("Plot-5")
graph.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(255, 213, 235)])
graph.SetPlotAreaColor(vi.FillType.FillType_Solid,
                       [vi.MakeColor(255, 255, 255)])
graph.SetCaption("Cursor Graphs")

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("Time")
xaxis.ModifyOption(vi.AxisOptions.AutoScale, False)
#yaxis
yaxis = graph.Axes(1)
yaxis.SetTitle("Amplitude")
yaxis.SetMaximum(10)
예제 #18
0
파일: speech.py 프로젝트: luwent/AIStudio
import torch
from torch import nn
import IStudio as iv

studio = iv.AIStudio("pytorch")

model = nn.Sequential()
model.add_module('W0', nn.Linear(8, 16))
model.add_module('tanh', nn.Tanh())
model.add_module('W1', nn.Linear(16, 1))

x = torch.randn(1, 8)

studio.RecordGraphDef(model(x), "speech",
                      dict(list(model.named_parameters()) + [('x', x)]))
예제 #19
0
파일: padanas.py 프로젝트: luwent/AIStudio
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import time

table = vi.IPDataTable("Data-2")
table.SetTableType(vi.TableType.General, True)
table.ModifyOption(
    vi.TableOption.ShowTabNavigator | vi.TableOption.ShowFormularBar, False)
table.ModifyOption(vi.TableOption.VerticalTab, True)
table.ModifyPopupMenu(0xFFFFFFFF, True)
table.SetTopHeaderNum(2)
table.SetLeftHeaderNum(0)

table.SelectSheet(0)
table.SetRowNumber(12)
table.SetColNumber(10)
table.SetSheetName(0, "Setup")

name = table.GetFont(1)
if (name is not None and len(name) > 0):
    p = 1
else:
    p = table.AddFont("", 14, 0, vi.FontStyleWeight.FontWeight_Bold)
table.JointCells(0, 0, 0, 1)
table.JointCells(1, 0, 1, 1)
table.SetCellFillColor(0, 0, 10, 1, 20)
예제 #20
0
def DictionaryToList(dict):
    keys = list(dict.keys())
    values = list(dict.values())
    datavalues = []
    colorvalues = []
    for i in values:
        if type(i) is tuple:
            datavalues.append(i[0])
            colorvalues.append(i[1])
        else:
            datavalues.append(i)
    return keys, datavalues, colorvalues


graph = vi.IPGraph("Pie-1")
graph.SetGraphCategory(vi.GraphCategory.Pie, vi.PlotStyle.PiePie)

#legend
legend = graph.GetLegend()
legend.SetVisible(True)

plotnum = graph.GetPlotCount()
for i in range(plotnum):
    graph.RemovePlot(0)
pie2D = graph.NewPlot("Pie1")
pie2D.SetPlotStyle(vi.PlotStyle.PiePie)
dict = {
    "Jan.": 2,
    "Feb.": 4,
    "Mar.": 5,
예제 #21
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
import sys
import tensorflow as tf
import numpy as np
import IStudio as iv

studio = iv.AIStudio("tensorflow")
filename = inspect.getframeinfo(inspect.currentframe()).filename
dir_path = os.path.dirname(os.path.abspath(filename))
mobile_file = dir_path + "\\rcnn_ssdlite_mobile.pb"
resnet_file = dir_path + "\\rcnn_resnet50.pb"
maskrnn_file = dir_path + "\\mask_rcnn_inceptionv2.pb"
label_file = dir_path + "\\mscoco_label_map.txt"
height, width = 800, 800
NUM_CLASSES = 90
max_boxes_to_draw = 100

#load label
with open(label_file) as f:
    label_list = f.read().splitlines()

camera = iv.IPCamera("Camera-1")
camera.ClearBoundingBox()
input_img = np.zeros((1, height, width, 3), dtype=np.uint8)

#load forzen graph
studio.LoadGraphDef(maskrnn_file)
예제 #22
0
파일: graph.py 프로젝트: IVAI2000/AIStudio
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np

graph1 = vi.IPGraph("Plot-1")
graph1.SetFrameColor(vi.PFillType.FillType_Solid, [0xFFFF0000])
graph1.SetPlotAreaColor(vi.PFillType.FillType_Solid, [0xFF00FF00])
graph1.SetCaption("Simple Plot-Graph Example")
#xaxis
xaxis = graph1.Axes(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("Time")
#yaxis
yaxis = graph1.Axes(1)
yaxis.SetTitle("Distance")
yaxis.SetMaximum(10)
yaxis.SetMinimum(-10)

#plot1
plotnum = graph1.GetPlotCount()
if plotnum < 1:
    plot1 = graph1.NewPlot("firstplot")
else:
    plot1 = graph1.Plots(0)
plot1.PlotXRange(0, 1)
#sinwave
fs = 100  # sample rate
예제 #23
0
파일: Transfer.py 프로젝트: luwent/AIStudio
import numpy as np
import IStudio as iv

transform = iv.IPFFTTransform(1024, 0, 0)

a = np.array([1 + 1.j, 2 + 2j], dtype=np.complex128)
b = np.empty([2], dtype=np.complex128)
print(a.dtype)
transform.SendRevComplex(a, b)
print(a)
print(b)
예제 #24
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random
import time

graph = vi.IPGraph("Graph3D-8")
graph.SetCaption("Annotation Example")
graph.SetMouseTrackingMode( vi.GraphMouseTrackingMode.TrackingMode_Rotation, True)
graph.SetOrientation(-422.2, 0, -347.7)

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(200)
xaxis.SetTitle( "Time" )
xaxis.ModifyOption( vi.AxisOptions.Reversed, True )
xaxis.SetTickLabelOrientation( vi.TextOrientationStyle.FaceCamera )

#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(-1)
yaxis.SetMaximum(1)
yaxis.SetTitle( "Amplitude" )
yaxis.ModifyOption( vi.AxisOptions.Reversed | vi.AxisOptions.AutoScroll, True )
yaxis.SetTickLabelOrientation( vi.TextOrientationStyle.FaceCamera )
예제 #25
0
파일: Pie3D.py 프로젝트: luwent/AIStudio
def DictionaryToList(dict):
    keys = list(dict.keys())
    values = list(dict.values())
    datavalues = []
    colorvalues = []
    for i in values:
        if type(i) is tuple:
            datavalues.append(i[0])
            colorvalues.append(i[1])
        else:
            datavalues.append(i)
    return keys, datavalues, colorvalues


graph = vi.IPGraph("Pie3D-1")
graph.SetGraphCategory(vi.GraphCategory.Pie, vi.PlotStyle.PiePie)
graph.SetOrientation(-422.2, 0, -347.7)
graph.SetPlotAreaScale(0.7)
zaxis = graph.Axes(2)
zaxis.SetMaximum(5)
xaxis = graph.Axes(0)
xaxis.SetTickColor(0xFFFF0000)

#legend
legend = graph.GetLegend()
legend.SetVisible(True)

lightcount = graph.GetLightCount()
if lightcount < 1:
    light = graph.NewLight("Light")
예제 #26
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random
import time

graph = vi.IPGraph("Graph3D-4")
graph.SetFrameColor(vi.PFillType.FillType_Solid, [vi.MakeColor(223, 218, 241)])
graph.SetPlotAreaColor(vi.PFillType.FillType_Solid,
                       [vi.MakeColor(255, 255, 255)])
graph.SetCaption("Annotation Graph Example")
graph.SetMouseTrackingMode(vi.PGraphMouseTrackingMode.TrackingMode_Rotation,
                           True)
graph.SetOrientation(-422.2, 0, -347.7)

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(200)
xaxis.SetTitle("Time")
xaxis.ModifyOption(vi.PAxisOptions.Reversed, True)
xaxis.SetTickLabelOrientation(vi.PTextOrientationStyle.FaceCamera)

#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(-1)
yaxis.SetMaximum(1)
예제 #27
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np

graph = vi.IPGraph("Plot-1")
graph.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(190, 223, 208)])
graph.SetPlotAreaColor(vi.FillType.FillType_Solid, [vi.MakeColor(255,255,255)])
graph.SetCaption("Simple Plot-Graph Example")

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("Time")
xaxis.ModifyOption(vi.AxisOptions.AutoScale, False)

#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(-10)
yaxis.SetMaximum(10)
yaxis.SetTitle("Distance")
yaxis.ModifyOption(vi.AxisOptions.AutoScale, False)

#plot1
plotnum = graph.GetPlotCount()
if plotnum < 1:
    plot1 = graph.NewPlot("Plot1")
예제 #28
0
def main(_):
    # Import data
    mnist = input_data.read_data_sets(studio.DataFolder, one_hot=True)
    # Create the model
    x = tf.placeholder(tf.float32, [None, 784])

    # Define loss and optimizer
    y_ = tf.placeholder(tf.float32, [None, 10])

    # Build the graph for the deep net
    y_conv, keep_prob = deepnn(x)

    
    with tf.name_scope('loss'):
        cross_entropy = tf.nn.softmax_cross_entropy_with_logits(labels=y_,
                logits=y_conv)
    cross_entropy = tf.reduce_mean(cross_entropy)
    studio.AddRecordScalar(cross_entropy, "loss")
    
    with tf.name_scope('adam_optimizer'):
        train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
    
    with tf.name_scope('accuracy'):
        correct_prediction = tf.equal(tf.argmax(y_conv, 1), tf.argmax(y_, 1))
        correct_prediction = tf.cast(correct_prediction, tf.float32)
    accuracy = tf.reduce_mean(correct_prediction)
    
    #record computation graph
    studio.RecordGraphDef(tf.get_default_graph(), "mnist_deep")
    summary = studio.GetRecordList() 
    
    studio.SetupCheckpoint()
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        #studio.RestoreCheckpoint(sess, "mnist_deep") 
         
        for i in range(7):
            batch = mnist.train.next_batch(50)
            #~ if i % 100 == 0:
                #~ train_accuracy = accuracy.eval(feed_dict={
                    #~ x: batch[0], y_: batch[1], keep_prob: 1.0})
                #~ print('step %d, training accuracy %g' % (i, train_accuracy))
                #~ #studio.RecordScalar(train_accuracy, "accuracy")
            #~ if i % 10 == 0:
            """record data for display"""
            summary_result, _ = sess.run([summary, train_step], feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
            cc = summary[0].eval()
            #print(summary_result)
                #studio.SaveRecordList(summary_result)
            #else:
            #   c0 = sess.run(train_step, feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
             #   print(c0) 
                #train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
        studio.SaveCheckpoint(sess, "mnist_deep") 
        print('test accuracy %g' % accuracy.eval(feed_dict={
            x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))

        #inference
        draw = iv.IPDraw("Draw2D-1")
        image3 = iv.IPGraph("Image-3")
        plot3 = image3.Plots(0)
        print("Start inference, draw number using draw pad")
        while(1):
            if(studio.GetKeyState(0x1B) < 0):
                break  
            # get draw image
            image = draw.GetDrawImage(28*28, 28, 28, 1, False)
            image.astype(np.float32)
            image /= (-image.max())
            image += 1
            #draw the normalized image
            plot3.ImageColor(image, 28, 28)
            xx = np.expand_dims(image, axis=0)
            inference = tf.argmax(y_conv, 1)
            results = sess.run([inference], feed_dict={x: xx, keep_prob: 1.0})
            print("You drawing is:", results)
            sleep(1)
예제 #29
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random

#topgraph
graph = vi.IPGraph("Plot-3")
graph.SetFrameColor(vi.PFillType.FillType_Solid, [vi.MakeColor(255, 235, 164)])
graph.SetPlotAreaColor(vi.PFillType.FillType_Solid,
                       [vi.MakeColor(255, 255, 255)])
graph.SetCaption("Multiple-Plot Graphs")

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("Time")
xaxis.ModifyOption(vi.PAxisOptions.AutoScale, False)
#yaxis
yaxis = graph.Axes(1)
yaxis.SetMinimum(0)
yaxis.SetMaximum(10)
yaxis.SetTitle("Amplitude")
yaxis.ModifyOption(vi.PAxisOptions.AutoScale, False)
#y axis on the other side
axisnum = graph.GetAxisCount()
if axisnum < 3:
예제 #30
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import IStudio as vi
import numpy as np
import random
import time

#topgraph
graph = vi.IPGraph("Image-3")
graph.SetFrameColor(vi.FillType.FillType_Solid, [vi.MakeColor(200,200,200)])
graph.SetPlotAreaColor(vi.FillType.FillType_Solid, [vi.MakeColor(255,255,255)])
graph.SetCaption("Image Graph")
palette = graph.SetPalette(0,1,True)

#xaxis
xaxis = graph.Axes(0)
xaxis.SetMinimum(0)
xaxis.SetMaximum(100)
xaxis.SetTitle("X")
xaxis.ModifyOption(vi.AxisOptions.AutoScale, False)
#yaxis
yaxis = graph.Axes(1)
yaxis.SetTitle("Y")
yaxis.SetMaximum(200)
yaxis.SetMinimum(0)
yaxis.ModifyOption(vi.AxisOptions.AutoScale, False)
graph.SetMouseTrackingMode(vi.GraphMouseTrackingMode.TrackingMode_ZoomX |vi.GraphMouseTrackingMode.TrackingMode_PanX, True )