balthou commited on
Commit
74f19b4
Β·
1 Parent(s): 4f6789c

add gifs for backend speeds

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. library.py +18 -5
  3. tutorial.md +8 -1
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *gif* filter=lfs diff=lfs merge=lfs -text
library.py CHANGED
@@ -7,26 +7,39 @@ from interactive_pipe import Curve, SingleCurve
7
  # -----------------
8
 
9
 
10
- def gen_color(frequency=0, isotropy=0.):
 
 
 
11
  lin_coord = np.linspace(0, 1., 256)
12
  X, Y = np.meshgrid(lin_coord, isotropy*lin_coord)
13
  radius = 0.5+0.5*np.cos(frequency*np.sqrt(X**2 + Y**2))
14
  return np.stack([np.abs(X), np.abs(Y), radius], axis=-1).clip(0, 1)
15
 
16
 
17
- def modify_geometry(img, effect="flip"):
 
 
 
18
  img = img[::-1] if "flip" in effect else img
19
  img = img[:, ::-1] if "mirror" in effect else img
20
  return img
21
 
22
 
23
- def change_color(img, bnw=True):
 
 
 
24
  if bnw:
25
  return np.mean(img, axis=-1, keepdims=True).repeat(3, axis=-1)
26
  return img
27
 
28
 
29
- def compare_by_splitting(img_1, img_2, ratio=0.5):
 
 
 
 
30
  out = np.zeros_like(img_1)
31
  split = int(ratio*img_1.shape[1])
32
  out[:, :split] = img_2[:, :split]
@@ -34,7 +47,7 @@ def compare_by_splitting(img_1, img_2, ratio=0.5):
34
  return out
35
 
36
 
37
- def extract_profile(img):
38
  luma = img.mean(axis=-1)
39
  h_profile = SingleCurve(y=luma[0, :], label="H profile")
40
  v_profile = SingleCurve(y=luma[:, 0], label="V profile")
 
7
  # -----------------
8
 
9
 
10
+ def gen_color(
11
+ frequency: int = 0, # discrete slider (int)
12
+ isotropy: float = 0., # continuous slider (float)
13
+ ) -> np.ndarray:
14
  lin_coord = np.linspace(0, 1., 256)
15
  X, Y = np.meshgrid(lin_coord, isotropy*lin_coord)
16
  radius = 0.5+0.5*np.cos(frequency*np.sqrt(X**2 + Y**2))
17
  return np.stack([np.abs(X), np.abs(Y), radius], axis=-1).clip(0, 1)
18
 
19
 
20
+ def modify_geometry(
21
+ img: np.ndarray,
22
+ effect: str = "flip" # dropdown menus (str)
23
+ ) -> np.ndarray:
24
  img = img[::-1] if "flip" in effect else img
25
  img = img[:, ::-1] if "mirror" in effect else img
26
  return img
27
 
28
 
29
+ def change_color(
30
+ img: np.ndarray,
31
+ bnw: bool = True # checkboxes (bool)
32
+ ):
33
  if bnw:
34
  return np.mean(img, axis=-1, keepdims=True).repeat(3, axis=-1)
35
  return img
36
 
37
 
38
+ def compare_by_splitting(
39
+ img_1: np.ndarray,
40
+ img_2: np.ndarray,
41
+ ratio: float = 0.5, # continuous slider (float)
42
+ ) -> np.ndarray:
43
  out = np.zeros_like(img_1)
44
  split = int(ratio*img_1.shape[1])
45
  out[:, :split] = img_2[:, :split]
 
47
  return out
48
 
49
 
50
+ def extract_profile(img: np.ndarray,) -> Curve:
51
  luma = img.mean(axis=-1)
52
  h_profile = SingleCurve(y=luma[0, :], label="H profile")
53
  v_profile = SingleCurve(y=luma[:, 0], label="V profile")
tutorial.md CHANGED
@@ -1,5 +1,7 @@
1
  # Tutorial
2
 
 
 
3
  ## Keep separation between "production code" (library / not interactive) & interactivity
4
  - πŸ’‘ One of the strength of interactive pipe is to avoid adding hundreds of lines of code dedicated to GUI (graphical user interfaces).
5
  - With interactive pipe, you have the choice to keep this design choice. Each processing block can be defined as a regular function, without even importing the `interactive` decorator. In a separate file, you'll add sliders.
@@ -52,4 +54,9 @@ def gen_color(
52
  ```
53
 
54
  - βž• Shortest code
55
- - βž– The decorated function can't be re-used somewhere else
 
 
 
 
 
 
1
  # Tutorial
2
 
3
+
4
+
5
  ## Keep separation between "production code" (library / not interactive) & interactivity
6
  - πŸ’‘ One of the strength of interactive pipe is to avoid adding hundreds of lines of code dedicated to GUI (graphical user interfaces).
7
  - With interactive pipe, you have the choice to keep this design choice. Each processing block can be defined as a regular function, without even importing the `interactive` decorator. In a separate file, you'll add sliders.
 
54
  ```
55
 
56
  - βž• Shortest code
57
+ - βž– The decorated function can't be re-used somewhere else
58
+
59
+ ## Backend choice
60
+ | πŸš€ Qt | 🐒 Gradio |
61
+ |:---:|:---:|
62
+ | ![QT](/pyqt.gif) | ![Gradio](/gradio.gif) |