Skip to content

Commit

Permalink
adapt to new bmz format
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 25, 2024
1 parent 59a4ccb commit 689ad55
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ else if (this.id == null && this.type.equals("space"))
"Current configuration: type='%s', id=%s",
type, "null"
));
else if (this.id == null && this.type.equals("batch"))
else if ((this.id == null || this.id != "b") && this.type.equals("batch"))
this.abreviation = "b";
else if (this.id != null && id.equals("channel"))
this.abreviation = "c";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected TensorSpecV04(Map<String, Object> tensorSpecMap, boolean input)
preprocessing = new ArrayList<TransformSpec>(preprocessingTensors.size());
for (Object elem : preprocessingTensors)
{
// TODO fix
if (((Map<String, Object>) elem).get("id") != null
&& ((Map<String, Object>) elem).get("id").equals("ensure_dtype"))
continue;
preprocessing.add(TransformSpec.build((Map<String, Object>) elem));
}
}
Expand All @@ -105,6 +109,10 @@ protected TensorSpecV04(Map<String, Object> tensorSpecMap, boolean input)
postprocessing = new ArrayList<TransformSpec>(postprocessingTensors.size());
for (Object elem : postprocessingTensors)
{
// TODO fix
if (((Map<String, Object>) elem).get("id") != null
&& ((Map<String, Object>) elem).get("id").equals("ensure_dtype"))
continue;
postprocessing.add(TransformSpec.build((Map<String, Object>) elem));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ protected TensorSpecV05(Map<String, Object> tensorSpecMap, boolean input)
preprocessing = new ArrayList<TransformSpec>(preprocessingTensors.size());
for (Object elem : preprocessingTensors)
{
// TODO fix
if (((Map<String, Object>) elem).get("id") != null
&& ((Map<String, Object>) elem).get("id").equals("ensure_dtype"))
continue;
preprocessing.add(TransformSpec.build((Map<String, Object>) elem));
}
}
Expand All @@ -108,6 +112,10 @@ protected TensorSpecV05(Map<String, Object> tensorSpecMap, boolean input)
postprocessing = new ArrayList<TransformSpec>(postprocessingTensors.size());
for (Object elem : postprocessingTensors)
{
// TODO fix
if (((Map<String, Object>) elem).get("id") != null
&& ((Map<String, Object>) elem).get("id").equals("ensure_dtype"))
continue;
postprocessing.add(TransformSpec.build((Map<String, Object>) elem));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public Map<String, Object> getSpecMap()
*/
public String getName()
{
return specMap == null ? null : (String) specMap.get("name");
if (specMap == null)
return null;
if (specMap.get("name") != null)
return (String) specMap.get("name");
return (String) specMap.get("id");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ private void buildPreprocessing() throws IllegalArgumentException, RuntimeExcept
List<TransformSpec> preprocessing = tt.getPreprocessing();
List<TransformationInstance> list = new ArrayList<TransformationInstance>();
for (TransformSpec transformation : preprocessing) {
// TODO fix
if (transformation.getName() == null)
continue;
list.add(TransformationInstance.create(transformation));
}
preMap.put(tt.getName(), list);
Expand All @@ -85,6 +88,9 @@ private void buildPostprocessing() throws IllegalArgumentException, RuntimeExcep
List<TransformSpec> preprocessing = tt.getPostprocessing();
List<TransformationInstance> list = new ArrayList<TransformationInstance>();
for (TransformSpec transformation : preprocessing) {
// TODO fix
if (transformation.getName() == null)
continue;
list.add(TransformationInstance.create(transformation));
}
postMap.put(tt.getName(), list);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/bioimage/modelrunner/numpy/DecodeNumpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public class DecodeNumpy {
/**
* PAttern that matches the metadata description of a numpy file
*/
public static final Pattern HEADER_PATTERN =
Pattern.compile("\\{'descr': '(.+)', 'fortran_order': (True|False), 'shape': \\((.*)\\),");
public static final Pattern HEADER_PATTERN =
Pattern.compile("\\{'descr': '(.+)', 'fortran_order': (True|False), 'shape': \\((.+?)\\)(?:\\s*,\\s*|\\s*)\\}");
/**
* Main method to test the ImgLib2 creation
* @param <T>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*-
* #%L
* Use deep learning frameworks from Java in an agnostic and isolated way.
* %%
* Copyright (C) 2022 - 2024 Institut Pasteur and BioImage.IO developers.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package io.bioimage.modelrunner.transformations;


/**
* TODO do it
*/
public class EnsureDtypeTransformation extends AbstractTensorPixelTransformation
{

private static String name = "ensure_dtype";

public EnsureDtypeTransformation()
{
super(name);
}
}

0 comments on commit 689ad55

Please sign in to comment.