Skip to content

Commit 1548bd8

Browse files
committed
chore: remove dead code for the now-removed "images" project type
The "images" project type used the IBM Visual Recognition service which is no longer available. This commit is a tiny bit of tidying up to remove the code that handled that type. (It's not super essential, as at the moment that code is just never called). I've also updated the version of TensorFlow used in the extension as there are a bunch of fixes and performance improvements that went into the version since we last built this. Signed-off-by: Dale Lane <dale.lane@uk.ibm.com>
1 parent 61fb9f7 commit 1548bd8

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

downloadtfjs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ ! -f "../src/com/kylecorry/ml4k/assets/model.json" ]; then
77
do
88
curl https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/group$i-shard1of1 -o ../src/com/kylecorry/ml4k/assets/group$i-shard1of1
99
done
10-
npm install @tensorflow/tfjs
10+
npm install @tensorflow/tfjs@3.12.0
1111
cp node_modules/@tensorflow/tfjs/dist/tf.min.js ../src/com/kylecorry/ml4k/assets/.
1212
npm install @ricokahler/pool
1313
cp node_modules/@ricokahler/pool/dist/index.js ../src/com/kylecorry/ml4k/assets/promisepool.js

src/com/kylecorry/ml4k/ML4KComponent.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ public void run() {
198198
data = ((ClassifyTextAction)classifyAction).text;
199199
classification = ml4k.classify(data);
200200
break;
201-
case ClassifyImage:
202-
data = ((ClassifyImageAction)classifyAction).imagePath;
203-
classification = ml4k.classify(loadImageFile(data));
204-
break;
205201
case ClassifyNumbers:
206202
YailList numbers = ((ClassifyNumbersAction)classifyAction).numbers;
207203
data = numbers.toString();
@@ -677,7 +673,6 @@ private void processNextAction(final String projectType, final NextAction action
677673
case "text":
678674
addTrainingDataToProject(action);
679675
break;
680-
case "images":
681676
case "imgtfjs":
682677
displayErrorMessage(EXPLAIN_API_KEY_TYPE_IMAGES);
683678
break;
@@ -691,7 +686,6 @@ private void processNextAction(final String projectType, final NextAction action
691686
break;
692687
case AddImageTraining:
693688
switch (projectType) {
694-
case "images":
695689
case "imgtfjs":
696690
addTrainingDataToProject(action);
697691
break;
@@ -711,7 +705,6 @@ private void processNextAction(final String projectType, final NextAction action
711705
case "numbers":
712706
addTrainingDataToProject(action);
713707
break;
714-
case "images":
715708
case "imgtfjs":
716709
displayErrorMessage(EXPLAIN_API_KEY_TYPE_IMAGES);
717710
break;
@@ -729,7 +722,6 @@ private void processNextAction(final String projectType, final NextAction action
729722
case "text":
730723
classifyTestDataOnServer(action);
731724
break;
732-
case "images":
733725
case "imgtfjs":
734726
displayErrorMessage(EXPLAIN_API_KEY_TYPE_IMAGES);
735727
break;
@@ -743,9 +735,6 @@ private void processNextAction(final String projectType, final NextAction action
743735
break;
744736
case ClassifyImage:
745737
switch (projectType) {
746-
case "images":
747-
classifyTestDataOnServer(action);
748-
break;
749738
case "imgtfjs":
750739
classifyImageWithTensorflow(((ClassifyImageAction)action).imagePath);
751740
break;
@@ -765,7 +754,6 @@ private void processNextAction(final String projectType, final NextAction action
765754
case "numbers":
766755
classifyTestDataOnServer(action);
767756
break;
768-
case "images":
769757
case "imgtfjs":
770758
displayErrorMessage(EXPLAIN_API_KEY_TYPE_IMAGES);
771759
break;
@@ -780,7 +768,6 @@ private void processNextAction(final String projectType, final NextAction action
780768
// ML model actions
781769
case TrainModel:
782770
switch (projectType) {
783-
case "images":
784771
case "text":
785772
case "numbers":
786773
trainModelWithWatson();
@@ -795,7 +782,6 @@ private void processNextAction(final String projectType, final NextAction action
795782
break;
796783
case CheckModelStatus:
797784
switch (projectType) {
798-
case "images":
799785
case "text":
800786
case "numbers":
801787
fetchModelStatusFromServer();

src/com/kylecorry/ml4k/ModelStatus.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ public static ModelStatus fromJson(String json) throws ML4KException {
2929
if (message == null || type == null){
3030
throw new ML4KException("JSON is not valid: " + json);
3131
}
32-
return new ModelStatus(code, message, type);
32+
if (type.equals("text") ||
33+
type.equals("imgtfjs") ||
34+
type.equals("numbers") ||
35+
type.equals("sounds"))
36+
{
37+
return new ModelStatus(code, message, type);
38+
}
39+
else {
40+
throw new ML4KException("Unexpected project type: " + type);
41+
}
3342
}
3443

3544
/**

0 commit comments

Comments
 (0)