mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-13 13:22:57 +00:00
no longer fails to compile (but w2l inference is broken)
This commit is contained in:
1 parent
c11ccc36d7
commit
69fba14fa4
9 files changed
+99
-39
No files matched your search
@@ -1,25 +1,75 @@
|
||||
use crate::buckets::bucket_paths::hash_to_bucket_path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// This is designed to make it centrally configurable where
|
||||
/// different types of objects are stored.
|
||||
pub struct BucketPathUnifier {
|
||||
|
||||
pub user_uploaded_w2l_templates_root: PathBuf,
|
||||
}
|
||||
|
||||
impl BucketPathUnifier {
|
||||
|
||||
pub fn user_audio_for_w2l_inference_path(audio_token: &str) -> String {
|
||||
pub fn user_audio_for_w2l_inference_path(&self, audio_token: &str) -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn end_bump_video_for_w2l_path(end_bump_filename: &str) -> String {
|
||||
pub fn end_bump_video_for_w2l_path(&self, end_bump_filename: &str) -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn precomputed_faces_for_w2l_path(token: &str) -> String {
|
||||
// eg. /user_uploaded_w2l_templates/1/5/1/151a[...60]_detected_faces.pickle
|
||||
pub fn precomputed_faces_for_w2l_path(&self, template_file_hash: &str) -> PathBuf {
|
||||
let faces_filename = format!("{}_detected_faces.pickle", &template_file_hash);
|
||||
let hashed_path = Self::hashed_directory_path(template_file_hash);
|
||||
|
||||
self.user_uploaded_w2l_templates_root
|
||||
.join(hashed_path)
|
||||
.join(faces_filename)
|
||||
}
|
||||
|
||||
pub fn pretrained_w2l_model_path(&self, model_name: &str) -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn pretrained_w2l_model_path(model_name: &str) -> String {
|
||||
"".to_string()
|
||||
pub fn hashed_directory_path(file_hash: &str) -> String {
|
||||
match file_hash.len() {
|
||||
0 => "".to_string(),
|
||||
1 => file_hash.to_string(),
|
||||
2 => format!("{}/", &file_hash[0..1]),
|
||||
3 => format!("{}/{}/", &file_hash[0..1], &file_hash[1..2]),
|
||||
_ => format!("{}/{}/{}/", &file_hash[0..1], &file_hash[1..2], &file_hash[2..3]),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::buckets::bucket_path_unifier::BucketPathUnifier;
|
||||
|
||||
#[test]
|
||||
fn hashed_directory_path_length_zero() {
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path(""), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashed_directory_path_length_one() {
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("a"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashed_directory_path_length_two() {
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("ab"), "a/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashed_directory_path_length_three() {
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("abc"), "a/b/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashed_directory_path_length_more() {
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("abcd"), "a/b/c/");
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("abcde"), "a/b/c/");
|
||||
assert_eq!(&BucketPathUnifier::hashed_directory_path("abcdef01234"), "a/b/c/");
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ pub fn hash_to_bucket_path(file_hash: &str,
|
||||
bail!("File length is too short");
|
||||
}
|
||||
|
||||
let optional_directory = optional_root_directory
|
||||
let root_directory = optional_root_directory
|
||||
.map(|root| PathBuf::from(root.to_string()))
|
||||
.unwrap_or(PathBuf::from("/"));
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn hash_to_bucket_path(file_hash: &str,
|
||||
&file_hash,
|
||||
);
|
||||
|
||||
let maybe_path = optional_directory
|
||||
let maybe_path = root_directory
|
||||
.join(file_path)
|
||||
.to_str()
|
||||
.map(|s| s.to_string());
|
||||
|
||||
@@ -43,7 +43,7 @@ pub struct W2lInferenceJobRecord {
|
||||
pub async fn query_w2l_inference_job_records(pool: &MySqlPool, num_records: u32)
|
||||
-> AnyhowResult<Vec<W2lInferenceJobRecord>>
|
||||
{
|
||||
let job_records = sqlx::query_as!(
|
||||
/*let job_records = sqlx::query_as!(
|
||||
W2lInferenceJobRecord,
|
||||
r#"
|
||||
SELECT
|
||||
@@ -67,7 +67,9 @@ WHERE
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
|
||||
Ok(job_records)
|
||||
Ok(job_records)*/
|
||||
|
||||
return Err(anyhow!("TODO"));
|
||||
}
|
||||
|
||||
pub async fn mark_w2l_inference_job_failure(pool: &MySqlPool,
|
||||
@@ -138,7 +140,7 @@ pub async fn insert_w2l_result(pool: &MySqlPool,
|
||||
duration_millis: u64)
|
||||
-> AnyhowResult<u64>
|
||||
{
|
||||
let model_token = random_prefix_crockford_token("W2L_TPL:", 32)?;
|
||||
/*let model_token = random_prefix_crockford_token("W2L_TPL:", 32)?;
|
||||
let updatable_slug = model_token.clone();
|
||||
|
||||
let query_result = sqlx::query!(
|
||||
@@ -170,10 +172,7 @@ SET
|
||||
model_token,
|
||||
template_type,
|
||||
updatable_slug,
|
||||
job.title.to_string(),
|
||||
job.creator_user_token.clone(),
|
||||
job.creator_ip_address.clone(),
|
||||
job.download_url.clone(),
|
||||
private_bucket_hash.to_string(),
|
||||
private_bucket_object_name.to_string(),
|
||||
private_bucket_cached_faces_object_name.to_string(),
|
||||
@@ -200,5 +199,6 @@ SET
|
||||
}
|
||||
};
|
||||
|
||||
Ok(record_id)
|
||||
Ok(record_id)*/
|
||||
return Err(anyhow!("TODO"));
|
||||
}
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
#![deny(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_imports)]
|
||||
#![warn(unused_must_use)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_variables)]
|
||||
//#![allow(warnings)]
|
||||
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
@@ -3,7 +3,6 @@ use log::{info,warn};
|
||||
use std::process::{Command, Stdio};
|
||||
use subprocess::{Popen, PopenConfig, Redirection};
|
||||
use std::fs::OpenOptions;
|
||||
use crate::script_execution::wav2lip_inference_command_OLD::Wav2LipInferenceCommand;
|
||||
|
||||
/// This command is used to run inference.
|
||||
/// It uses preprocessed face files so that it's much faster.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#![deny(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_variables)]
|
||||
#![warn(unused_must_use)]
|
||||
//#![allow(warnings)]
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
#![deny(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_variables)]
|
||||
//#![allow(warnings)]
|
||||
|
||||
pub mod util;
|
||||
|
||||
use crate::util::anyhow_result::AnyhowResult;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#![deny(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_imports)]
|
||||
#![warn(unused_must_use)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_variables)]
|
||||
//#![allow(warnings)]
|
||||
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
+19
-17
@@ -1,8 +1,8 @@
|
||||
#![deny(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_imports)]
|
||||
#![warn(unused_must_use)]
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_variables)]
|
||||
//#![allow(warnings)]
|
||||
|
||||
#[macro_use] extern crate serde_derive;
|
||||
@@ -153,11 +153,10 @@ async fn main() -> AnyhowResult<()> {
|
||||
DEFAULT_TEMP_DIR);
|
||||
|
||||
// TODO: In the future, we may want to enable downloading images or audio files.
|
||||
//let download_script = easyenv::get_env_string_or_default(
|
||||
// "DOWNLOAD_SCRIPT",
|
||||
// "./scripts/download_gdrive.py");
|
||||
//
|
||||
//let google_drive_downloader = GoogleDriveDownloadCommand::new(&download_script);
|
||||
let download_script = easyenv::get_env_string_or_default(
|
||||
"DOWNLOAD_SCRIPT",
|
||||
"./scripts/download_gdrive.py");
|
||||
let google_drive_downloader = GoogleDriveDownloadCommand::new(&download_script);
|
||||
|
||||
let temp_directory = PathBuf::from(temp_directory);
|
||||
|
||||
@@ -175,6 +174,8 @@ async fn main() -> AnyhowResult<()> {
|
||||
.connect(&db_connection_string)
|
||||
.await?;
|
||||
|
||||
let inference_script = "TODO".to_string();
|
||||
|
||||
let inferencer = Inferencer {
|
||||
download_temp_directory: temp_directory,
|
||||
mysql_pool,
|
||||
@@ -205,7 +206,7 @@ async fn main_loop(inferencer: Inferencer) {
|
||||
loop {
|
||||
let num_records = 1;
|
||||
|
||||
let query_result = query_w2l_template_upload_job_records(
|
||||
let query_result = query_w2l_inference_job_records(
|
||||
&inferencer.mysql_pool,
|
||||
num_records)
|
||||
.await;
|
||||
@@ -302,15 +303,16 @@ async fn process_job(inferencer: &Inferencer, job: &W2lInferenceJobRecord) -> An
|
||||
let temp_dir = format!("temp_{}", job.id);
|
||||
let temp_dir = TempDir::new(&temp_dir)?;
|
||||
|
||||
let download_url = job.download_url.as_ref()
|
||||
.map(|c| c.to_string())
|
||||
.unwrap_or("".to_string());
|
||||
//let download_url = job.download_url.as_ref()
|
||||
// .map(|c| c.to_string())
|
||||
// .unwrap_or("".to_string());
|
||||
|
||||
// ==================== DOWNLOAD FILE ==================== //
|
||||
|
||||
info!("Calling downloader...");
|
||||
let download_filename = inferencer.google_drive_downloader
|
||||
.download_file(&download_url, &temp_dir).await?;
|
||||
//let download_filename = inferencer.google_drive_downloader
|
||||
// .download_file(&download_url, &temp_dir).await?;
|
||||
let download_filename = "TODO";
|
||||
|
||||
// ==================== PROCESS FACES ==================== //
|
||||
|
||||
@@ -324,12 +326,12 @@ async fn process_job(inferencer: &Inferencer, job: &W2lInferenceJobRecord) -> An
|
||||
let is_image = false; // TODO: Don't always treat as video.
|
||||
let spawn_process = false;
|
||||
|
||||
inferencer.w2l_processor.execute(
|
||||
/*inferencer.w2l_processor.execute(
|
||||
&download_filename,
|
||||
&cached_faces_filename,
|
||||
&output_metadata_filename,
|
||||
is_image,
|
||||
spawn_process)?;
|
||||
spawn_process)?;*/
|
||||
|
||||
// ==================== CHECK ALL FILES EXIST AND GET METADATA ==================== //
|
||||
|
||||
@@ -364,7 +366,7 @@ async fn process_job(inferencer: &Inferencer, job: &W2lInferenceJobRecord) -> An
|
||||
let mut maybe_video_preview_filename : Option<PathBuf> = None;
|
||||
let mut maybe_video_preview_object_name : Option<String> = None;
|
||||
|
||||
if file_metadata.is_video {
|
||||
/*if file_metadata.is_video {
|
||||
let preview_filename = format!("{}_preview.webp", &download_filename);
|
||||
|
||||
inferencer.ffmpeg_video_preview_generator.execute(
|
||||
@@ -400,7 +402,7 @@ async fn process_job(inferencer: &Inferencer, job: &W2lInferenceJobRecord) -> An
|
||||
let preview_object_path = format!("{}_preview.webp", full_object_path);
|
||||
maybe_image_preview_object_name = Some(preview_object_path);
|
||||
maybe_image_preview_filename = Some(image_preview_path);
|
||||
}
|
||||
}*/
|
||||
|
||||
// ==================== UPLOAD TO BUCKETS ==================== //
|
||||
|
||||
|
||||
Reference in new issue
Block a user