File size: 6,726 Bytes
595469c
a2e2b1b
595469c
 
 
 
a2e2b1b
595469c
05e6598
595469c
 
 
 
 
 
 
a2e2b1b
595469c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2e2b1b
 
595469c
a2e2b1b
595469c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
_id: fal
author: Anton Breslavskii | https://github.com/breslavsky
description: Cloud platform for serving media-generating AI models
readme: |-
  - added **Deblur**
  - added **generate short clips SVD v1.1**
title: Fal AI
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/fal.yaml
version: 2
nodes:
  deblur_fal:
    _id: deblur_fal
    arrange:
      x: 180
      y: 120
    category:
      _id: image_processing
      title: en=Work with images;ru=Работа с изображениями
    environment:
      FAL_KEY:
        title: Fal API KEY
        type: string
        scope: global
    inputs:
      image:
        order: 1
        title: en=Image;ru=Изображение
        type: image
        required: true
    outputs:
      image:
        title: en=Image;ru=Изображение
        type: image
    package: fal
    script: |-
      export async function run({ inputs, state }) {

          const { image } = inputs;
          const { FatalError, RepeatNode, NextNode } = DEFINITIONS;

          const FAL_KEY = env?.variables?.get('FAL_KEY');
          if (!FAL_KEY) {
              throw new FatalError('Please, set your API key for Fal AI');
          }

          const { fal } = require('@fal-ai/client');
          fal.config({ credentials: FAL_KEY });

          if (!state) {
              const { request_id: task } = await fal.queue.submit("fal-ai/nafnet/deblur", {
                  input: {
                      image_url: image
                  }
              });
              return RepeatNode.from({ state: { task }, delay: 3000 });
          } else {
              const { task } = state;
              const { status, queue_position: position } = await fal.queue.status("fal-ai/nafnet/deblur", {
                  requestId: task,
                  logs: true,
              });
              console.log('Status & position', status, position);
              switch (status) {
                  case 'COMPLETED':
                      // get results
                      break;
                  case 'IN_PROGRESS':
                  case 'IN_QUEUE':
                  default:
                      return RepeatNode.from({ delay: 5000, state });
              }

              const { data } = await fal.queue.result("fal-ai/nafnet/deblur", { requestId: task });
              const { image: { url } } = data;
              return NextNode.from({ outputs: { image: url } })
          }

      }
    source: catalog
    title: en=Deblur;ru=Убрать размытие
    version: 1
  fast_svd_lcm_fal:
    _id: fast_svd_lcm_fal
    arrange:
      x: 510
      y: 60
    category:
      _id: video_generation
      title: en=Generate videos;ru=Генерация видео
    environment:
      FAL_KEY:
        title: Fal API KEY
        type: string
        scope: global
    groups:
      inputs:
        extra:
          order: 1
          title: Additional settings
    inputs:
      image:
        order: 1
        title: en=Image;ru=Изображение
        type: image
        required: true
      steps:
        order: 3
        title: Steps
        description: The conditoning augmentation determines the amount of noise that will be added to the conditioning frame. The higher the number, the more noise there will be, and the less the video will look like the initial image. Increase it for more motion.
        group: extra
        type: integer
        min: 1
        max: 20
        step: 1
        default: 4
      motionBucketId:
        order: 1
        title: Motion Bucket Id
        description: The motion bucket id determines the motion of the generated video. The higher the number, the more motion there will be.
        group: extra
        type: integer
        min: 1
        max: 255
        step: 1
        default: 127
      condAug:
        order: 2
        title: Cond Aug
        description: The conditoning augmentation determines the amount of noise that will be added to the conditioning frame. The higher the number, the more noise there will be, and the less the video will look like the initial image. Increase it for more motion.
        group: extra
        type: float
        min: 0.02
        max: 10
        step: 0.01
        default: 0.02
      fps:
        order: 4
        title: FPS
        description: The FPS of the generated video. The higher the number, the faster the video will play. Total video length is 25 frames
        group: extra
        type: integer
        min: 1
        max: 25
        step: 1
        default: 10
    outputs:
      video:
        title: en=Video;ru=Видео
        type: video
    package: fal
    script: |-
      export async function run({ inputs, state }) {

          const { image, motionBucketId, condAug, steps, fps } = inputs;
          const { FatalError, RepeatNode, NextNode } = DEFINITIONS;

          const FAL_KEY = env?.variables?.get('FAL_KEY');
          if (!FAL_KEY) {
              throw new FatalError('Please, set your API key for Fal AI');
          }

          const { fal } = require('@fal-ai/client');
          fal.config({ credentials: FAL_KEY });

          if (!state) {
              const payload = {
                  input: {
                      image_url: image,
                      motion_bucket_id: motionBucketId || 127,
                      cond_aug: condAug || 0.02,
                      steps: steps || 4,
                      fps: fps || 10

                  }
              };
              const { request_id: task } = await fal.queue.submit("fal-ai/fast-svd-lcm", payload);
              return RepeatNode.from({ state: { task, payload }, delay: 3000 });
          } else {
              const { task } = state;
              const { status, queue_position: position } = await fal.queue.status("fal-ai/fast-svd-lcm", {
                  requestId: task,
                  logs: true,
              });
              console.log('Status & position', status, position);
              switch (status) {
                  case 'COMPLETED':
                      // get results
                      break;
                  case 'IN_PROGRESS':
                  case 'IN_QUEUE':
                  default:
                      return RepeatNode.from({ delay: 5000, state });
              }

              const { data } = await fal.queue.result("fal-ai/fast-svd-lcm", { requestId: task });
              console.log(JSON.stringify(data));
              const { video: { url } } = data;
              return NextNode.from({ outputs: { video: url } })
          }

      }
    source: catalog
    title: en=Generate short video clip;ru=Создать короткий видео-клип
    version: 1