File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
src/huggingface_hub/inference Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -2913,10 +2913,11 @@ def zero_shot_image_classification(
2913
2913
# Raise ValueError if input is less than 2 labels
2914
2914
if len (labels ) < 2 :
2915
2915
raise ValueError ("You must specify at least 2 classes to compare." )
2916
-
2917
- inputs = {"image" : _b64_encode (image ), "candidateLabels" : "," .join (labels )}
2918
- parameters = {"hypothesis_template" : hypothesis_template }
2919
- payload = _prepare_payload (inputs , parameters = parameters )
2916
+ parameters = {
2917
+ "candidate_labels" : labels ,
2918
+ "hypothesis_template" : hypothesis_template ,
2919
+ }
2920
+ payload = _prepare_payload (image , parameters = parameters , expect_binary = True )
2920
2921
response = self .post (
2921
2922
** payload ,
2922
2923
model = model ,
Original file line number Diff line number Diff line change @@ -2985,10 +2985,11 @@ async def zero_shot_image_classification(
2985
2985
# Raise ValueError if input is less than 2 labels
2986
2986
if len (labels ) < 2 :
2987
2987
raise ValueError ("You must specify at least 2 classes to compare." )
2988
-
2989
- inputs = {"image" : _b64_encode (image ), "candidateLabels" : "," .join (labels )}
2990
- parameters = {"hypothesis_template" : hypothesis_template }
2991
- payload = _prepare_payload (inputs , parameters = parameters )
2988
+ parameters = {
2989
+ "candidate_labels" : labels ,
2990
+ "hypothesis_template" : hypothesis_template ,
2991
+ }
2992
+ payload = _prepare_payload (image , parameters = parameters , expect_binary = True )
2992
2993
response = await self .post (
2993
2994
** payload ,
2994
2995
model = model ,
You can’t perform that action at this time.
0 commit comments