faster calibration curve generation
jellyfin intergration
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "gallery_store.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using json = nlohmann::json;
|
||||
@@ -11,14 +13,24 @@ ActorGallery load_gallery(const std::string& path) {
|
||||
if (!f.is_open())
|
||||
throw std::runtime_error("load_gallery: cannot open " + path);
|
||||
|
||||
std::cerr << "[gallery] loading " << path << "..." << std::flush;
|
||||
auto t0 = std::chrono::steady_clock::now();
|
||||
|
||||
json j;
|
||||
f >> j;
|
||||
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
std::cerr << " parsed JSON in "
|
||||
<< std::chrono::duration<double>(t1 - t0).count() << "s\n";
|
||||
|
||||
ActorGallery gallery;
|
||||
for (const auto& ja : j.at("actors")) {
|
||||
ActorGallery::Actor actor;
|
||||
actor.imdb_id = ja.at("imdb_id").get<std::string>();
|
||||
actor.name = ja.at("name").get<std::string>();
|
||||
actor.imdb_id = ja.value("imdb_id", "");
|
||||
actor.tmdb_id = ja.value("tmdb_id", "");
|
||||
// older make_jellyfin_gallery.py galleries used "jellyfin_person_id"
|
||||
actor.jellyfin_id = ja.value("jellyfin_id", ja.value("jellyfin_person_id", ""));
|
||||
actor.name = ja.at("name").get<std::string>();
|
||||
|
||||
if (ja.contains("source_images"))
|
||||
actor.source_images = ja.at("source_images").get<std::vector<std::string>>();
|
||||
@@ -30,6 +42,14 @@ ActorGallery load_gallery(const std::string& path) {
|
||||
|
||||
gallery.actors.push_back(std::move(actor));
|
||||
}
|
||||
|
||||
size_t n_emb = 0;
|
||||
for (const auto& actor : gallery.actors) n_emb += actor.embeddings.size();
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
std::cerr << "[gallery] built " << gallery.actors.size() << " actors / "
|
||||
<< n_emb << " embeddings in "
|
||||
<< std::chrono::duration<double>(t2 - t1).count() << "s\n";
|
||||
|
||||
return gallery;
|
||||
}
|
||||
|
||||
@@ -40,6 +60,8 @@ void save_gallery(const std::string& path, const ActorGallery& gallery) {
|
||||
for (const auto& actor : gallery.actors) {
|
||||
json ja;
|
||||
ja["imdb_id"] = actor.imdb_id;
|
||||
ja["tmdb_id"] = actor.tmdb_id;
|
||||
ja["jellyfin_id"] = actor.jellyfin_id;
|
||||
ja["name"] = actor.name;
|
||||
ja["source_images"] = actor.source_images;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user