Skip to content

Commit

Permalink
working on unsupervised annnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
thesteve0 committed Nov 14, 2024
1 parent 91377d1 commit 117021c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 2_data_splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

dataset_name = "photo_album"

# This just takes a sample of the original dataset and creates
# a new dataset which is has a random 300 samples.
# For real work we probably would just want to tag this data. Something like training,
# test, validation

if __name__ == "__main__":
print("starting")
dataset = fo.load_dataset(dataset_name)
# A DatasetView is a shallow copy of the original dataset.This means,
# if your dataset is persisted, any data or schema changes to the view will be persisted to the original dataset.
# If you don't want to affect the original dataset you must make the view a clone of the original data.
shuffle_view = dataset.shuffle()
training_view = shuffle_view[0:300].clone()
training_view = shuffle_view[0:300].clone("play_photos", persistent=True)
training_view.save()

print("finished")
27 changes: 27 additions & 0 deletions 4_generate_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from http.cookiejar import debug

import fiftyone as fo
import fiftyone.zoo as foz


if __name__ == '__main__':
dataset = fo.load_dataset("play_photos")
clip = foz.load_zoo_model(
"clip-vit-base32-torch",
text_prompt="A photo of a",
classes= ["boy", "girl", "man", "woman", "people", "dog", "cat", "bird", "insect", "monkey", "crustacean",
"fish", "animal", "plant", "flower", "landscape", "architecture", "not an animal, plant, landscape, person, or building"])
# alexnet = foz.load_zoo_model("alexnet-imagenet-torch")
# dense201 = foz.load_zoo_model("densenet201-imagenet-torch")
# fasterrcnn = foz.load_zoo_model("faster-rcnn-resnet50-fpn-coco-torch")
# yoloseg = foz.load_zoo_model("yolo11x-seg-coco-torch")

dataset.apply_model(clip, label_field="default_prediction")
dataset.set_values("ground_truth", fo.Classification(label=str(dataset.values("default_prediction.label"))))
# dataset.apply_model(dense201, label_field="dense201")
# dataset.apply_model(alexnet, label_field="alexnet")
# dataset.apply_model(fasterrcnn, label_field="faster_rcnn")
# dataset.apply_model(yoloseg, label_field="yolo_seg")

session = fo.launch_app(dataset)
session.wait()

0 comments on commit 117021c

Please sign in to comment.