public DataOuterClass.BoundingBox serializeBoundingBox() { return DataOuterClass.BoundingBox.newBuilder() .setTopRow(top()) .setLeftCol(left()) .setBottomRow(bottom()) .setRightCol(right()) .build(); } }
@Test public void cropping() { client.addInputs() .plus( ClarifaiInput.forInputValue( ClarifaiImage.of("@@sampleTrain") .withCrop(Crop.create() .top(0.2F) .left(0.4F) .bottom(0.3F) .right(0.6F) ) ) ) .allowDuplicateURLs(true) .executeSync(); }
@Test public void shouldBeSuccessfulForFocusModel() { ClarifaiResponse<List<ClarifaiOutput<Focus>>> response = client.getDefaultModels().focusModel().predict() .withInputs(ClarifaiInput.forImage(METRO_NORTH_IMAGE_URL)).executeSync(); assertTrue(response.isSuccessful()); Focus focus = response.get().get(0).data().get(0); assertTrue(focus.value() >= 0); assertTrue(focus.value() <= 1); assertTrue(focus.crop().bottom() >= 0); assertTrue(focus.crop().top() >= 0); assertTrue(focus.crop().left() >= 0); assertTrue(focus.crop().right() >= 0); assertTrue(focus.density() >= 0); }
@Test public void shouldSucceedWhenValidRequestWithFaceFeedback() { ModelFeedbackRequest request = client.modelFeedback(client.getDefaultModels().travelModel().id()) .withInputId("@inputId") .withImageUrl(FAMILY_IMAGE_URL) .withRegions( RegionFeedback.make( Crop.create().top(0.1f).bottom(0.2f).left(0.3f).right(0.4f), Feedback.ACCURATE ) .withFaceFeedback( FaceFeedback.make( Arrays.asList(ConceptFeedback.forIdAndValue("face", true)), Arrays.asList(ConceptFeedback.forIdAndValue("face", true)) ) )) .withEndUserId("@endUserId") .withSessionId("@sessionId") .withEventType("annotation") .withOutputId("@outputId"); assertSuccess(request); } }
@Retry @Test public void t01a_addInputs() throws Exception { assertSuccess(client.addInputs() .plus(ClarifaiInput.forInputValue(ClarifaiImage.of(KOTLIN_LOGO_IMAGE_FILE) .withCrop(Crop.create() .top(0.1F) .left(0.1F) .bottom(0.9F) .right(0.9F) ) ) .withID("foo1") .withConcepts(Concept.forID("concept1").withValue(false)) ) ); }
@Test public void shouldSucceedWhenValidRequestWithRegions() { ModelFeedbackRequest request = client.modelFeedback(client.getDefaultModels().travelModel().id()) .withInputId("@inputId") .withImageUrl(FAMILY_IMAGE_URL) .withRegions( RegionFeedback.make( Crop.create().top(0.1f).bottom(0.2f).left(0.3f).right(0.4f), Feedback.ACCURATE ) .withConceptFeedbacks(ConceptFeedback.forIdAndValue("car", false))) .withEndUserId("@endUserId") .withSessionId("@sessionId") .withEventType("annotation") .withOutputId("@outputId"); assertSuccess(request); }