Giter Club home page Giter Club logo

Comments (4)

sanjanag avatar sanjanag commented on June 10, 2024

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.

MichalOleszak avatar MichalOleszak commented on June 10, 2024

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.

sanjanag avatar sanjanag commented on June 10, 2024

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.

jwmueller avatar jwmueller commented on June 10, 2024

See also: #210

from cleanvision.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.