Skip to content

Commit

Permalink
now really works locally; i had to make a release .jar locally and te…
Browse files Browse the repository at this point in the history
…st access to file there
  • Loading branch information
RusFortunat committed Nov 13, 2024
1 parent d399d09 commit 97949d5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
15 changes: 15 additions & 0 deletions spring.log
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,18 @@ Caused by: java.lang.ClassNotFoundException: com.guessNumbersWithAI.model.Neural
... 28 common frames omitted

2024-11-13T16:30:38.361+01:00 ERROR 23460 --- [guessNumbersWithAI] [http-nio-8080-exec-2] c.g.controller.ViewController : Cannot invoke "java.net.URL.toString()" because the return value of "java.lang.Class.getResource(String)" is null
2024-11-13T16:59:04.956+01:00 ERROR 23572 --- [guessNumbersWithAI] [restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Web server failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

2024-11-13T16:59:35.672+01:00 ERROR 10864 --- [guessNumbersWithAI] [http-nio-8080-exec-1] c.g.controller.ViewController : class path resource [classpath:net_params_size784_256_10_lr0.001_trainEps100.txt] cannot be opened because it does not exist
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;

import java.io.File;
import java.io.FileWriter;
import java.io.InputStream;
import java.util.ArrayList;

@Controller
Expand Down Expand Up @@ -43,10 +46,12 @@ public String hanglePostMapping(@ModelAttribute("NeuralNetwork") NeuralNetwork o

try{
// load network parameters from the file
Resource resource=resourceLoader.getResource(
/*Resource resource=resourceLoader.getResource(
"classpath:net_params_size784_256_10_lr0.001_trainEps100.txt");*/
Resource resource= resourceLoader.getResource(
"classpath:net_params_size784_256_10_lr0.001_trainEps100.txt");
File file = resource.getFile();
ourNeuralNetwork.loadNetworkParameters(file);
InputStream inputStream = resource.getInputStream();
ourNeuralNetwork.loadNetworkParameters(inputStream);

// create input vector by processing raw pixel image data; we turn 280x280 px image into 28x28 px image
double[] inputVector = drawnImages.processRawInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

package com.guessNumbersWithAI.model;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Scanner;

public class NeuralNetwork {
Expand Down Expand Up @@ -102,7 +99,7 @@ public void forward(double[] input) throws RuntimeException{


// loads the parameters of the chosen network
public void loadNetworkParameters(File networkParamsFile) throws Exception{
public void loadNetworkParameters(InputStream networkParamsFile) throws Exception{

Scanner reader = new Scanner(networkParamsFile);

Expand Down
Binary file modified src/main/resources/image-database.mv.db
Binary file not shown.

0 comments on commit 97949d5

Please sign in to comment.