Serializing a trained model on Android - weka

I have a problem to serialize a trained Multilayer Perceptron model on Android. I am using WekaSTRIPPED.jar (WEKA-for-Android)
My code is :
Classifier cModel = new MultilayerPerceptron();
try {
cModel.buildClassifier(trainFile);
weka.core.SerializationHelper.write(Directory + "/FourFModels/MLP.model", cModel);
Log.e("MLP model", "created");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The errors I got:
06-14 12:23:48.776: E/AndroidRuntime(336): FATAL EXCEPTION: main
06-14 12:23:48.776: E/AndroidRuntime(336): java.lang.IllegalStateException: Could not execute method of the activity
06-14 12:23:48.776: E/AndroidRuntime(336): at android.view.View$1.onClick(View.java:3599)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.view.View.performClick(View.java:4204)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.view.View$PerformClick.run(View.java:17355)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.os.Handler.handleCallback(Handler.java:725)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.os.Handler.dispatchMessage(Handler.java:92)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.os.Looper.loop(Looper.java:137)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.lang.reflect.Method.invoke(Method.java:511)
06-14 12:23:48.776: E/AndroidRuntime(336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-14 12:23:48.776: E/AndroidRuntime(336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-14 12:23:48.776: E/AndroidRuntime(336): at dalvik.system.NativeStart.main(Native Method)
06-14 12:23:48.776: E/AndroidRuntime(336): Caused by: java.lang.reflect.InvocationTargetException
06-14 12:23:48.776: E/AndroidRuntime(336): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.lang.reflect.Method.invoke(Method.java:511)
06-14 12:23:48.776: E/AndroidRuntime(336): at android.view.View$1.onClick(View.java:3594)
06-14 12:23:48.776: E/AndroidRuntime(336): ... 11 more
06-14 12:23:48.776: E/AndroidRuntime(336): Caused by: java.lang.StackOverflowError
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.SerializationHandleMap.get(SerializationHandleMap.java:63)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.dumpCycle(ObjectOutputStream.java:425)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:754)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeNewArray(ObjectOutputStream.java:1134)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1662)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
06-14 12:23:48.776: E/AndroidRuntime(336): at java.io.ObjectOutputStream.writeNewArray(ObjectOutputStream.java:1205)
Any help is greatly appreciated.

Related

WinUI 3 - C++/WinRT DataTemplateSelector : Unable to cast object

I want to create a Template Selector in WinUI 3 using c++/WinRT.
For example, if the type of a person is "Employee" i want to show his name in Red and if is "Unemployee", in Blue.
I recreate the example from Microsoft but i got
this error
The code is here . All VisualStudio components are up to date.
XAML code:
<StackPanel>
<Page>
<Page.Resources>
<DataTemplate x:Key="template1" x:DataType="x:Int32">
<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{ThemeResource SystemChromeLowColor}">
<TextBlock Text="{x:Bind}" />
</Button>
</DataTemplate>
<DataTemplate x:Key="template2" x:DataType="x:Int32">
<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{ThemeResource SystemAccentColor}">
<TextBlock Text="{x:Bind}" />
</Button>
</DataTemplate>
<local:Selector x:Key="mySelector"
firstTemplate="{StaticResource template1}"
secondTemplate="{StaticResource template2}"/>
</Page.Resources>
</Page>
<ListView
ItemTemplateSelector = "{StaticResource mySelector}">
</ListView>
</StackPanel>
Thanks!

Flask app getting 0x8007000d error with IIS

I'm trying to get a very basic flask app to work on IIS 10 running on Windows Server 2019.
I followed the HTTPPlatform Handler instructions from: https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019
But I keep getting HTTP 500.19 errors with error code 0x8007000d. From googling, I suspect the problem is in my web.config, but I don't know what is wrong. The app works fine from the command line.
This is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\python39\python.exe"
arguments="D:\inetpub\wwwroot\flasktest.py"
stdoutLogEnabled="true"
stdoutLogFile="d:\logs\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="9010" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
This is my app.py:
from flask import Flask, render_template
app = Flask(__name__)
#app.debug = True
#app.route("/", methods=('GET', 'POST'))
def home():
return render_template('main.html', hello = 'hello world')
if __name__ == '__main__':
app.run(host='0.0.0.0',port=9010)
this is my main.html
{% extends 'layout.html' %}
{% block content %}
<div class="container">
<div class="leftrow1">
{{ hello }}
</div>
<div class="leftrow2">
</div>
<div class="leftrow3">
</div>
<div class="leftrow4">
</div>
<div class="main_frame_1">
</div>
<div class="main_frame_2">
</div>
</div>
{% endblock content %}
and this is the layout.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
</head>
<body>
{% block content %}
{% endblock content %}
</body>
Update: based on comments received, adding additional error info
This is the error I get (without installing httpplatformhandler), nothing is in eventlog when this occurs:
This is the error I get after installing httpplatformhandler:
with the 500.3 message, I also get a bunch of event 1000 from HttpPlatformHandler in event log:
It seems that you don't have the correct permission to access D:\python39\python.exe and D:\inetpub\wwwroot\flasktest.py.
Open IIS Manager -> Select the site you added the HttpPlatformHandler
Click Handler Mappings in the feature view -> select the HttpPlatformHandler
Click Edit Feature Permission in the Action Panel
Make sure you have check the Execute permission

Show progressbar on the top in the existing MainPage.xaml in UWP app(c++) by masking all the other controls in UI

I have an UWP C++ app for getting some information which takes a long time to load .While startup,its taking time to get the information and update the UI.So I thought of putting a progress ring while the UI is getting data. I need the progress ring to show on the UI during the loading time in MainPage.xaml thereby making the existing controls invisible.But it is not coming on top of UI.After getting data to UI,progress ring should disappear and all the controls should be visible.
<Page
x:Class="Ft_Information.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Ft_Information"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="MainWindow_Loaded" BorderThickness="10" IsTabStop="True">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="ftnfoGrid" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25*" />
<RowDefinition Height="500*" />
<RowDefinition Height="100*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="500*" />
<ColumnDefinition Width="800*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1">
<TextBox x:Name="ProductNameText" x:Uid="ProductName" TextWrapping="Wrap" BorderThickness="0" IsTabStop="False" FontSize="13" IsReadOnly="True" />
<StackPanel Grid.Row="2" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" Margin="55,5.333,0.333,-5" VerticalAlignment="Stretch">
<ProgressRing Name="ProgressRingLbl" Height="120" Width="109" HorizontalAlignment="Left"
Foreground="Blue" IsActive="True" Visibility="Visible" VerticalAlignment="Center" Margin="0,0,0,0"/>
</StackPanel>
</Grid>
</Grid>
</Page>
MainPage::MainPage()
{
ProductNameText->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ProgressRingLbl->IsActive = true;
ProgressRingLbl->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
MainPage::FuntouploadUI()
{
.............
//after getting data
ProgressRingLbl->IsActive = false;
ProgressRingLbl->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ProductNameText->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
Still the progress bar is not showing anywhere in the UI.
I write a simple demo below.You can use this code in your application to test if the progress ring can show in the UI.
<Page ...>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Background="AliceBlue">
<TextBlock x:Name="MyTextBlock" Height="50" FontSize="16" Margin="0,20,0,20">Hello,world</TextBlock>​
<Button x:Name="MyButton" Click="Button_Click">click me</Button>​
<ProgressRing x:Name="MyProgressRing" Height="120" Width="109" Foreground="Blue" IsActive="True" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Center"></ProgressRing>​
</StackPanel>
</Grid>
</Page>
MainPage::MainPage()
{​
InitializeComponent();​
MyTextBlock->Visibility = Windows::UI::Xaml::Visibility::Collapsed;​
MyButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;​
MyProgressRing->IsActive = true;​
MyProgressRing->Visibility = Windows::UI::Xaml::Visibility::Visible;​
​
}
The reason why progress ring not working was we are using another view to show the mainpage.xaml as a child to its root grid.When I moved the progress ring part to that xaml ,it is working fine. Since progress ring is working as a seperate UI thread it is not called by the mainpage.

cfchart horizontal bar labels crowded

I have created a simple chart in coldfusion 10. For some reason the labels on Y-axis are too crowded. Granted they are long texts (not more than 100 characters though), they should still appear on single lines instead of wrapping. Here is the screen-shot:
<cfchart chartheight="1000" chartwidth="1000" showxgridlines="no" showygridlines="no" showborder="no" fontbold="no" fontitalic="no" show3d="no" rotated="no" sortxaxis="no" showlegend="no" showmarkers="no" format="jpg" xaxistitle="Issues">
<cfchartseries type="horizontalbar" serieslabel="Survey Count" >
<cfchartdata item="lwkencfkenklnr lknevfvfv ghthrtg y;l;lm;'m jkbjed lknl klnelvkn lknlknrweknn" value="10">
<cfchartdata item="lewfll; ;lmrtgbjweb vkn wkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfewflfojewmlrm" value="20">
<cfchartdata item="efklnwkln lknkleng lwkencfkenefe klnr lknevlknl klnelvkn lknlknrweknn ewe" value="40">
<cfchartdata item="lkenglk klkn kjbghdchg lwk ewefrewf ncfkenklnr lknevlknl klnelvkn lknlknrweknn" value="10">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="60">
<cfchartdata item="lwkencfkenklnr lkneffvlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="80">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="50">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="5">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="100">
<cfchartdata item="lwkencfke btgnklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="20">
<cfchartdata item="lwkencfkenklnr lknevlvvrgr knl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwkencfkenklnr lkneffvfg vlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="50">
<cfchartdata item="lwkffdfdf encfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="60">
<cfchartdata item="lwkenc hy jujuyjj fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwkencrfrf fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="80">
<cfchartdata item="lwkencfrfrf h thtt yyuyu kenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="25">
<cfchartdata item="lwkencefef ferrgrg fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="38">
<cfchartdata item="lwken hthththcfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="2">
<cfchartdata item="jjkjkkjbjk lwkencfkeefefnklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="120">
<cfchartdata item=";l;m;';' frfegtgrt tgt kencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="12">
<cfchartdata item="knklnknk lknlkne lknklnewf lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="55">
<cfchartdata item="el;mvlml ;lmlmll ';,;lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="88">
<cfchartdata item="lwkg;lm;l ';,;' nkneknfv encfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="6">
<cfchartdata item="knklnekgn klnqd legegwkeeg ncfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwgerg;,e;' ';,hytlhmwjkbfh kjkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="25">
<cfchartdata item="lwkencfkenfwekfnwkln knklnklnd l;ml;fklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="150">
</cfchartseries>
Thanks.
CF10 uses multiple charting engines: ZingChart for format="html" and WebCharts3D for all other formats ie "flash|jpg|png".
As mentioned, using ZingCharts directly would offer more control. However, to answer your question your current chart is generated with WebCharts3D. You can modify the chart's behavior by using a custom style. To disable wrapping use isMultiline="false". (See also the charting utility in {cfroot\charting\webcharts.bat}).
<cfsavecontent variable="customStyle"><?xml version="1.0" encoding="UTF-8"?>
<frameChart>
<xAxis>
<labelStyle isMultiline="false" isHideOverlapped="false" orientation="Horizontal"/>
</xAxis>
</frameChart>
</cfsavecontent>
<cfchart style="#customStyle#"
chartheight="1000"
chartwidth="1000" ....>
</cfchart>

How to insert a asp:TabPanel inside a asp:Repeater?

When I try to execute the below code it gives me the error "There was an error rendering the control. Check to make sure all properties are valid".
Inner repeater works fine inside the tab container. But outer does not allow to have a tab panel within it.
Tab containers are not available in asp.net toolbox and therefore I installed Ajax tool kit and added that to Visual Studio and refer that Assembly as follows.
<%# Register Assembly="AjaxControlToolkit, Version=1.0.11119.25966, Culture=neutral,PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Repeater ID="ProjectRepeater" runat="server">
<ItemTemplate>
<cc1:TabContainer ID="TestTabContainer" runat="server">
<cc1:TabPanel ID="TestTabPanel" HeaderText="technologies" runat="server">
<ContentTemplate>
<asp:Repeater id="SkillsRepeater" runat="server">
<ItemTemplate>
<div class="project-technologies" id="SkillZone" runat="server">
<a id="skill" href='<%# "http://vingo/Pages/projectresults.aspx?k="+DataBinder.Eval(Container.DataItem, "Skill")%>' target="_blank"><%# DataBinder.Eval(Container.DataItem, "Skill")%></a>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
EDIT: Outer repeater code
<asp:Repeater ID="P" runat="server">
<ItemTemplate>
<cc1:TabContainer ID="TTC" runat="server">
<cc1:TabPanel ID="TTP" HeaderText="t" runat="server">
<ContentTemplate>
<asp:Repeater id="A" runat="server">
<ItemTemplate>
<%--Code--%>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</ItemTemplate>
</asp:Repeater>
Instead of a asp.nett Repeater I could use the below code and it did the expected work of a asp.net Repeater and flexibility is much higher than when using asp:Repeaters
function JsonPCallBack(result) {
for (var technology in result) {
$('body').append('<div OuterDiv id=OuterDivId><div class=project-technologies id=SkillZone><a id=skill href=http://vingo/Pages/projectresults.aspx?k=' + technology + 'target=_blank></a></div>');
}
}