|
| 1 | +import com.mindee.MindeeClientV2; |
| 2 | +import com.mindee.input.LocalInputSource; |
| 3 | +import com.mindee.v2.product.classification.ClassificationClassifier; |
| 4 | +import com.mindee.v2.product.classification.ClassificationResponse; |
| 5 | +import com.mindee.v2.product.classification.ClassificationResult |
| 6 | +import com.mindee.v2.product.classification.params.ClassificationParameters; |
| 7 | +import java.io.File; |
| 8 | +import java.io.IOException; |
| 9 | + |
| 10 | +public class SimpleMindeeClientV2 { |
| 11 | + |
| 12 | + public static void main(String[] args) |
| 13 | + throws IOException, InterruptedException |
| 14 | + { |
| 15 | + String apiKey = "MY_API_KEY"; |
| 16 | + String filePath = "/path/to/the/file.ext"; |
| 17 | + String modelId = "MY_MODEL_ID"; |
| 18 | + |
| 19 | + // Init a new client |
| 20 | + MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey); |
| 21 | + |
| 22 | + // Set inference parameters |
| 23 | + // Note: modelId is mandatory. |
| 24 | + ClassificationParameters classificationParams = ClassificationParameters |
| 25 | + // ID of the model, required. |
| 26 | + .builder(modelId) |
| 27 | + .build(); |
| 28 | + |
| 29 | + // Load a file from disk |
| 30 | + LocalInputSource inputSource = new LocalInputSource(filePath); |
| 31 | + |
| 32 | + // Send for processing |
| 33 | + ClassificationResponse response = mindeeClient.enqueueAndGetResult( |
| 34 | + ClassificationResponse.class, |
| 35 | + inputSource, |
| 36 | + classificationParams |
| 37 | + ); |
| 38 | + |
| 39 | + // Print a summary of the response |
| 40 | + System.out.println(response.getInference().toString()); |
| 41 | + |
| 42 | + // Access the classification result |
| 43 | + ClassificationResult result = response.getInference().getResult(); |
| 44 | + ClassificationClassifier classification = result.getClassification(); |
| 45 | + } |
| 46 | +} |
0 commit comments