88hours commited on
Commit
b10a5fa
·
1 Parent(s): 976b772

Write Step 2 to download data

Browse files
Files changed (2) hide show
  1. requirements.txt +2 -0
  2. s2-download-data.py +47 -0
requirements.txt CHANGED
@@ -1 +1,3 @@
1
  gradio
 
 
 
1
  gradio
2
+ langchain-predictionguard
3
+ IPython
s2-download-data.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from PIL import Image
3
+ # You can use your own uploaded images and captions.
4
+ # You will be responsible for the legal use of images that
5
+ # you are going to use.
6
+
7
+ url1='http://farm3.staticflickr.com/2519/4126738647_cc436c111b_z.jpg'
8
+ cap1='A motorcycle sits parked across from a herd of livestock'
9
+
10
+ url2='http://farm3.staticflickr.com/2046/2003879022_1b4b466d1d_z.jpg'
11
+ cap2='Motorcycle on platform to be worked on in garage'
12
+
13
+ url3='https://i.natgeofe.com/n/548467d8-c5f1-4551-9f58-6817a8d2c45e/NationalGeographic_2572187_3x2.jpg'
14
+ cap3='a cat laying down stretched out near a laptop'
15
+
16
+ img1 = {
17
+ 'flickr_url': url1,
18
+ 'caption': cap1,
19
+ 'image_path' : './shared_data/motorcycle_1.jpg'
20
+ }
21
+
22
+ img2 = {
23
+ 'flickr_url': url2,
24
+ 'caption': cap2,
25
+ 'image_path' : './shared_data/motorcycle_2.jpg'
26
+ }
27
+
28
+ img3 = {
29
+ 'flickr_url' : url3,
30
+ 'caption': cap3,
31
+ 'image_path' : './shared_data/cat_1.jpg'
32
+ }
33
+
34
+ def download_images():
35
+ # download images
36
+ imgs = [img1, img2, img3]
37
+ for img in imgs:
38
+ data = requests.get(img['flickr_url']).content
39
+ with open(img['image_path'], 'wb') as f:
40
+ f.write(data)
41
+
42
+ for img in [img1, img2, img3]:
43
+ image = Image.open(img['image_path'])
44
+ caption = img['caption']
45
+ print(image)
46
+ print(caption)
47
+