ariG23498 HF Staff commited on
Commit
cbe536c
·
verified ·
1 Parent(s): 0555b23

Upload Anzhc_Anzhcs_YOLOs_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Anzhc_Anzhcs_YOLOs_0.py +30 -0
Anzhc_Anzhcs_YOLOs_0.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ # Couldn't find a valid YOLO version tag.
11
+ # Replace XX with the correct version.
12
+ from ultralytics import YOLOvXX
13
+
14
+ model = YOLOvXX.from_pretrained("Anzhc/Anzhcs_YOLOs")
15
+ source = 'http://images.cocodataset.org/val2017/000000039769.jpg'
16
+ model.predict(source=source, save=True)
17
+ with open('Anzhc_Anzhcs_YOLOs_0.txt', 'w') as f:
18
+ f.write('Everything was good in Anzhc_Anzhcs_YOLOs_0.txt')
19
+ except Exception as e:
20
+ with open('Anzhc_Anzhcs_YOLOs_0.txt', 'w') as f:
21
+ import traceback
22
+ traceback.print_exc(file=f)
23
+ finally:
24
+ from huggingface_hub import upload_file
25
+ upload_file(
26
+ path_or_fileobj='Anzhc_Anzhcs_YOLOs_0.txt',
27
+ repo_id='model-metadata/custom_code_execution_files',
28
+ path_in_repo='Anzhc_Anzhcs_YOLOs_0.txt',
29
+ repo_type='dataset',
30
+ )