File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -767,3 +767,37 @@ def __str__(self):
767
767
json_str = {"name" : self .name , "type" : self .type , "workspace" : self .__workspace }
768
768
769
769
return json .dumps (json_str , indent = 2 )
770
+
771
+ def image (self , image_id : str ) -> Dict :
772
+ """
773
+ Fetch the details of a specific image from the Roboflow API.
774
+
775
+ Args:
776
+ image_id (str): The ID of the image to fetch.
777
+
778
+ Returns:
779
+ Dict: A dictionary containing the image details.
780
+
781
+ Example:
782
+ >>> import roboflow
783
+
784
+ >>> rf = roboflow.Roboflow(api_key="YOUR_API_KEY")
785
+
786
+ >>> project = rf.workspace().project("PROJECT_ID")
787
+
788
+ >>> image_details = project.image("image-id")
789
+ """
790
+ url = f"{ API_URL } /{ self .__workspace } /{ self .__project_name } /images/{ image_id } " f"?api_key={ self .__api_key } "
791
+
792
+ data = requests .get (url ).json ()
793
+
794
+ if "error" in data :
795
+ raise RuntimeError (data ["error" ])
796
+
797
+ if "image" not in data :
798
+ print (data , image_id )
799
+ raise RuntimeError ("Image not found" )
800
+
801
+ image_details = data ["image" ]
802
+
803
+ return image_details
You can’t perform that action at this time.
0 commit comments