This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def frame_diff_with_anchor(video_tensor, anchor_frame_index): | |
""" | |
Compute the frame difference for a video tensor using an anchor frame. | |
video_tensor should have shape (batch_size, channels, frames, height, width) | |
anchor_frame_index is the index of the anchor frame around which diffs are computed | |
""" | |
# Ensure that the anchor frame is within the correct range | |
num_frames = video_tensor.shape[2] | |
if not (0 <= anchor_frame_index < num_frames): | |
raise ValueError("anchor_frame_index is out of range.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from animatediff.pipelines.pipeline_animation import AnimationPipeline | |
import torch | |
from diffusers import AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler | |
from tqdm.auto import tqdm | |
from transformers import CLIPTextModel, CLIPTokenizer | |
from animatediff.models.unet import UNet3DConditionModel | |
from diffusers.utils.import_utils import is_xformers_available | |
from safetensors import safe_open |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE OverloadedStrings #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres=# explain (analyze, buffers) UPDATE payloads | |
postgres-# SET state='dequeued' | |
postgres-# WHERE id in | |
postgres-# ( SELECT p1.id | |
postgres(# FROM payloads AS p1 | |
postgres(# WHERE p1.state='enqueued' | |
postgres(# ORDER BY p1.modified_at ASC | |
postgres(# FOR UPDATE SKIP LOCKED | |
postgres(# LIMIT 1 | |
postgres(# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION enqueue(count int8, x anyarray) RETURNS void AS $$ | |
DECLARE | |
startValue int8; | |
lastValue int8; | |
currentValue int8; | |
partition_name text; | |
doubleCount int8; | |
BEGIN | |
doubleCount := 2 * count; | |
SELECT nextval('modified_index') INTO currentValue ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2019-12-29 21:13:35 GMT [42602]: LOG: duration: 2.476 ms plan: | |
Query Text: INSERT INTO users (email, password, name) VALUES ('[email protected]', 'password', 'name1') RETURNING id | |
Insert on public.users (cost=0.00..0.02 rows=1 width=382) (actual time=2.471..2.472 rows=1 loops=1) | |
Output: id | |
Buffers: shared hit=9 read=11 dirtied=9 | |
I/O Timings: read=1.879 | |
-> Result (cost=0.00..0.02 rows=1 width=382) (actual time=1.100..1.100 rows=1 loops=1) | |
Output: nextval('users_id_seq'::regclass), clock_timestamp(), clock_timestamp(), '[email protected]'::character varying(140), '\x70617373776f7264'::bytea, 'name1'::text | |
Buffers: shared hit=9 read=4 dirtied=2 | |
I/O Timings: read=1.028 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aroundAll :: forall a. ((a -> IO ()) -> IO ()) -> SpecWith a -> Spec | |
aroundAll withFunc specWith = do | |
(var, stopper, asyncer) <- runIO $ | |
(,,) <$> newEmptyMVar <*> newEmptyMVar <*> newIORef Nothing | |
let theStart :: IO a | |
theStart = do | |
thread <- async $ do | |
withFunc $ \x -> do | |
putMVar var x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- I think this is a a monoid. Basically it is used to either mappend to a value or replace the value | |
data Lastoid a = Replace a | Mappend a | Nope | |
instance Semigroup a => Semigroup (Lastoid a) where | |
x <> y = case (x, y) of | |
(r@Replace {}, _ ) -> r | |
(Mappend a , Replace b) -> Replace $ a <> b | |
(Mappend a , Mappend b) -> Mappend $ a <> b | |
(Nope , x ) -> x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type WidgetFlow t m a = Workflow t (VtyWidget t m) a | |
testScreen | |
:: (Reflex t, Show a, Show b, Monad m) | |
=> a | |
-- ^ Input | |
-> (a -> VtyWidget t m (Event t b)) | |
-- ^ Screen to test | |
-> (b -> WidgetFlow t m ()) | |
-- ^ Next continuation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- What I am struggling to do is sequence to looping things. First I have a loop where the output is feed into the | |
-- next step as input until it completes. Then the next loop starts. | |
-- I doubt this works ... I'm trying to test it now ... anyway I don't like it and feel like | |
-- there must be an easier way. | |
advance :: (Adjustable t m, MonadHold t m, Monad m, MonadFix m) | |
=> m (Event t (Maybe a)) | |
-- ^ initial | |
-> (a -> m (Event t (Maybe a))) |
NewerOlder