File size: 3,442 Bytes
27d916b 9d4363a 27d916b 9d4363a 27d916b 9d4363a 27d916b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os; os.chdir('..')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# os.mkdir(\"ai_gen_images\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['https://cdn.discordapp.com/attachments/988028621421686834/988592559897059378/ac325c7f-b984-454a-bb62-e41dcd3fd5b6_StevenMertens_Bill_Sienkiewicz_technology__Jack_Kirby_machines__retro_futuristic_ghibli_matte_painting.png',\n",
" 'https://cdn.discordapp.com/attachments/986263515713110056/988592330741252166/2735cb78-3bbe-419a-905c-c5e91dbed653_Erkan_Cerit_None.png',\n",
" 'https://cdn.discordapp.com/attachments/988028621421686834/988592225803993118/a278dac1-035b-47e3-a4b2-f168ec626b51_StevenMertens_Bill_Sienkiewicz_technology__Jack_Kirby_machines__retro_futuristic_ghibli_matte_painting.png',\n",
" 'https://cdn.discordapp.com/attachments/988028621421686834/988592214944907274/86e8ee74-05a3-48ce-9895-0be954752673_StevenMertens_Bill_Sienkiewicz_technology__Jack_Kirby_machines__retro_futuristic_ghibli_matte_painting.png',\n",
" 'https://cdn.discordapp.com/attachments/982990243621908480/988592166035140608/f191002c-0f09-4139-a38e-64beba3e7084_MissTwistedRose_cats_with_many_eyes_floating_in_colorful_glowing_swirling_whisps_occult_inspired_emerging_from_the_v.png']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import json\n",
"\n",
"urls= json.load(open(\"research/urls.json\"))\n",
"urls[:5]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"250133"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(urls)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 2%|▏ | 5243/250133 [19:09<15:23:18, 4.42it/s]"
]
}
],
"source": [
"from tqdm import tqdm\n",
"import requests\n",
"i=0\n",
"\n",
"\n",
"for url in tqdm(urls):\n",
" filename= f\"ai_gen_images/image_{i}.png\"\n",
" i+=1\n",
" try:\n",
" response= requests.get(url)\n",
" if response.ok:\n",
" with open(filename, \"wb\") as f:\n",
" f.write(response.content)\n",
" else:\n",
" print(\"response not ok: \", url)\n",
"\n",
" except:\n",
" print(url)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|