rose-omer commited on
Commit
4cc9a2d
·
verified ·
1 Parent(s): 42ea52d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from bing_image_downloader import downloader
3
+ import shutil
4
+ import os
5
+
6
+ def downloader_images(search_query, limit, adult_filter_off, timeout=20):
7
+ # Bing'den resim indirme işlemi
8
+ adult_filter = adult_filter_off == "True"
9
+ downloader.download(
10
+ search_query,
11
+ limit=limit,
12
+ adult_filter_off=adult_filter,
13
+ force_replace=False,
14
+ timeout=timeout
15
+ )
16
+ # İndirilen resimleri zip dosyası olarak paketle
17
+ output_dir = f'dataset/{search_query}'
18
+ zip_filename = f'{search_query}.zip'
19
+ shutil.make_archive(search_query, 'zip', output_dir)
20
+ # Zip dosyasının tam yolunu al
21
+ zip_path = f'{zip_filename}'
22
+ return zip_path
23
+
24
+ # Gradio arayüzü oluştur
25
+ interface = gr.Interface(
26
+ fn=downloader_images,
27
+ inputs=[
28
+ gr.Textbox(label='Aranacak kelime'),
29
+ gr.Slider(1, 100, step=5, label='Görsel sayısı'),
30
+ gr.Radio(["True", "False"], label="Korumalı mod", value="True")
31
+ ],
32
+ outputs=gr.File(label="İndirilen Görseller"),
33
+ title="Bing ile Görsel İndirme",
34
+ description="İndirmek istediğiniz resmi tanımlayınız. İlgili ayarlardan korumalı mod seçeneğini ve indirmek istediğiniz görsel sayısını belirleyebilirsiniz.",
35
+ examples=[
36
+ ["kedi", 20, "True"]
37
+ ]
38
+ )
39
+
40
+ # Arayüzü başlat
41
+ interface.launch(share=True)