图像提取器库可帮助用户在任何日期和时间通过互联网下载任何类型的图像。这些图像将作为作业下载,然后让用户知道图像已下载。
很多时候,我们需要一堆图像才能工作。我们可以考虑这样的例子,例如在猫和狗图像上训练机器学习模型,或者只需单击一下即可在我们的笔记本电脑上拥有数百张漂亮的桌面/移动壁纸。在这种情况下,我们立即需要数百张图像。这个问题可以使用图像提取器库来解决。可以实现以下用例:
$ pip install ImageExtractor
from flask import Flask
from flask_cors import cross_origin
from ImageExtractor . Extractor import ImageExtractor Class
import datetime
import threading
import time
import os
app = Flask ( __name__ )
class ThreadClass :
def __init__ ( self , req_id , time_to_sleep ,):
self . req_id = str ( req_id )
self . time_to_sleep = time_to_sleep
self . thread = threading . Thread ( target = self . sleep )
self . thread . start ()
def sleep ( self ):
try :
# Sleep for the given time
time . sleep ( self . time_to_sleep )
# Wait until the zip file is not ready
while not os . path . exists ( self . req_id + '_zipfile.zip' ):
print ( 'File not exists' )
time . sleep ( 5 )
print ( 'File exists now' )
time . sleep ( 30 )
# Deleting the file after 10 seconds
ImageExtractor Class . delete_file ( self . req_id )
print ( 'Files are deleted' )
except Exception as e :
print ( e )
# Home page route
@ app . route ( '/' , methods = [ 'GET' ])
@ cross_origin ()
def index ():
try :
# Creating the object of ImageExtractor Class
image_extractor = ImageExtractor Class ()
# Current datetime
current = datetime . datetime . now ()
# The scheduled datetime
date_inserted = current + datetime . timedelta ( minutes = 5 )
date_str = str ( date_inserted . year ) + '-' + str ( date_inserted . month ) + '-' + str ( date_inserted . day )
time_str = str ( date_inserted . hour ) + ':' + str ( date_inserted . minute )
req_id , time_to_sleep = image_extractor . schedule_job ( 'some_sample_query' , date_str , time_str , 54 )
# Time to sleep the thread
time_to_sleep = current + datetime . timedelta ( seconds = time_to_sleep )
total_seconds_sleep = time_to_sleep - datetime . datetime . now ()
# Total seconds to sleep the thread
total_seconds_sleep = int ( total_seconds_sleep . total_seconds ())
ThreadClass ( req_id , total_seconds_sleep )
return '<h1> req id is ' + str ( req_id ) + ' and time_to_sleep is ' + str ( total_seconds_sleep ) + ' seconds</h1>'
except Exception as e :
return "<h1> Error is " + str ( e ) + "</h1>"
if __name__ == '__main__' :
app . debug = True
app . run ()
您已经准备好出发了!此时,在给定的日期和时间,图像将开始下载。
想做出贡献吗?伟大的!
要修复错误或增强现有模块,请执行以下步骤:
git checkout -b new-feature
git commit -am " New feature added "
git push origin new-feature
如果您发现任何错误或对可以实现的新功能有一些想法,您可以在此处提出问题,也可以直接向我们发送电子邮件:[email protected]。
请包含示例查询及其相应的结果。
客户:
服务器:
如果您有任何反馈,请通过 [email protected] 联系我们
回答 - 不。用户可以简单地提交作业并继续执行其他任务。任务结束后,将在用户端创建 zip 文件。
Ans - 一次最多可以下载 2000 张图像。如果需要更多,我们可以简单地再次提交查询。
高级设计文档
低级设计文档
线框
建筑学
麻省理工学院许可证
版权所有 (c) [2021] [Shreyas Parab]
特此免费授予获得本软件及相关文档文件(“软件”)副本的任何人不受限制地使用本软件,包括但不限于使用、复制、修改、合并的权利、发布、分发、再许可和/或销售软件的副本,并允许向其提供软件的人员这样做,但须满足以下条件:
上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和不侵权的保证。在任何情况下,作者或版权持有者均不对因本软件或本软件中的使用或其他交易而产生或与之相关的任何索赔、损害或其他责任负责,无论是合同、侵权行为还是其他行为。软件。