Comments (4)
Hi @MichalOleszak !
Thanks for your question. You can use cleanvision on in-memory images by wrapping them in a hugginface Dataset object.
Here's a code snippet doing that
from PIL import Image
import os
from datasets import Dataset
from cleanvision import Imagelab
if __name__ == "__main__":
# loading images in-memory
files = os.listdir("./tests/data")
fpaths = [os.path.join("./tests/data", f) for f in files]
image_list = [Image.open(f) for f in fpaths]
# construct in-memory dataset
mydict = {"image": image_list}
dataset = Dataset.from_dict(mydict)
# call cleanvision on this dataset
imagelab = Imagelab(hf_dataset=dataset, image_key="image")
imagelab.find_issues()
imagelab.report()
print(imagelab.get_stats())
from cleanvision.
Hey @sanjanag,
Thanks a lot for a quick reply!
The solution you suggest works well, but from my quick&dirty experiments it seems to follow that for a single image (which is the use case I'm the most interested in) it's actually slower than dumping to a tempdir.
I assume you are not planning to expose APIs in the form of get_brightness(img: Image) -> float
?
from cleanvision.
Hi @MichalOleszak ! That sure looks like a good use case. We already have the code for computing these stats in bulk but not per image. But it should not be difficult to get those. You can find related code in image_property.py. If you take a look at the implemented ImageProperty classes, the calculate() method computes the raw value of the statistic and the get_scores() method converts it into a score between 0 and 1.
Would you be interested in working on exposing these statistics methods from the package for the use case mentioned above?
from cleanvision.
See also: #210
from cleanvision.
Related Issues (20)
- Add link checker workflow HOT 2
- static page showing large number of examples of different images with issues HOT 9
- Images with a `*.JPG` extension are missed HOT 5
- [documentation] add guide of issue types
- Improve efficiency of cleanvision on large datasets HOT 2
- Expose methods for calculating statistics on individual images for on the fly evaluation HOT 3
- Extend CleanVision to run on video data HOT 21
- Handle PIL UnidentifiedImageError exception when running cleanvision on local image folder dataset
- Unit test for truncate title in case the title is too long in visualization HOT 2
- `psutils` and `s3fs` not installed errors HOT 4
- Exact duplicates always calculated HOT 6
- What are these errors/warning?
- RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase HOT 3
- Catch duplicate entries in filepaths argument
- Unlock bmp picture file HOT 1
- Quick-start tutorial for using VideoLab HOT 1
- Unit tests for VideoLab HOT 1
- Enhancing pre-commits
- Drop support for Python 3.7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cleanvision.