Spaces:
Sleeping
Sleeping
Reduce images available to 20. Print images. Select 1 random image.
Browse files
app.py
CHANGED
|
@@ -18,8 +18,15 @@ from datasets import load_dataset
|
|
| 18 |
dataset = load_dataset("merve/coco")
|
| 19 |
|
| 20 |
df = pd.dataset
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Get image database
|
| 25 |
##curl -X GET \
|
|
@@ -33,27 +40,4 @@ print(df.head(12))
|
|
| 33 |
##model = AutoModelForVision2Seq.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 34 |
|
| 35 |
|
| 36 |
-
import os
|
| 37 |
-
import random
|
| 38 |
-
|
| 39 |
-
path = "https://huggingface.co/Salesforce/blip-image-captioning-large"
|
| 40 |
-
|
| 41 |
-
images = []
|
| 42 |
-
|
| 43 |
-
# This will get each root, dir and file list in the path specified recursively (like the "find" command in linux, but separating files, from directories, from paths).
|
| 44 |
-
# root is the full path from your specified path to the the directory it is inspecting
|
| 45 |
-
# dirs is a list containing all the directories found in the current inspecting directory
|
| 46 |
-
# files is a list containing all the files found in the current inspecting directory
|
| 47 |
-
for root, dirs, files in os.walk(path):
|
| 48 |
-
# This will filter all the .png files in case there is something else in the directory
|
| 49 |
-
# If your directory only has images, you can do this:
|
| 50 |
-
# images = files
|
| 51 |
-
# instead of filtering the '.png' images with the for loop // filter for jgp
|
| 52 |
-
for f in files:
|
| 53 |
-
if f[-4:] == '.jpg':
|
| 54 |
-
images.append(f)
|
| 55 |
-
|
| 56 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 57 |
-
|
| 58 |
-
print(random.choice(images))
|
| 59 |
demo.launch()
|
|
|
|
| 18 |
dataset = load_dataset("merve/coco")
|
| 19 |
|
| 20 |
df = pd.dataset
|
| 21 |
+
# Select first 20 rows
|
| 22 |
+
df.iloc[:20,:]
|
| 23 |
+
print ("Print to show the 20 images available.")
|
| 24 |
+
print ("The app will then select an image for further exploration.")
|
| 25 |
+
print(df.head(20))
|
| 26 |
|
| 27 |
+
# Use the sample command
|
| 28 |
+
selected_image = df.sample(n=1)
|
| 29 |
+
print (selected_image)
|
| 30 |
|
| 31 |
# Get image database
|
| 32 |
##curl -X GET \
|
|
|
|
| 40 |
##model = AutoModelForVision2Seq.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 41 |
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
demo.launch()
|