hysts HF Staff commited on
Commit
8f7021c
·
1 Parent(s): 48c77d9

Add files

Browse files
.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
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.pre-commit-config.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-executables-have-shebangs
6
+ - id: check-json
7
+ - id: check-merge-conflict
8
+ - id: check-shebang-scripts-are-executable
9
+ - id: check-toml
10
+ - id: check-yaml
11
+ - id: end-of-file-fixer
12
+ - id: mixed-line-ending
13
+ args: ["--fix=lf"]
14
+ - id: requirements-txt-fixer
15
+ - id: trailing-whitespace
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ rev: v0.12.1
18
+ hooks:
19
+ - id: ruff-check
20
+ args: ["--fix"]
21
+ - id: ruff-format
22
+ - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.16.1
24
+ hooks:
25
+ - id: mypy
26
+ args: ["--ignore-missing-imports"]
27
+ additional_dependencies:
28
+ [
29
+ "types-python-slugify",
30
+ "types-pytz",
31
+ "types-PyYAML",
32
+ "types-requests",
33
+ ]
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.10
.vscode/extensions.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recommendations": [
3
+ "ms-python.python",
4
+ "charliermarsh.ruff",
5
+ "streetsidesoftware.code-spell-checker",
6
+ "tamasfe.even-better-toml"
7
+ ]
8
+ }
.vscode/settings.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "files.insertFinalNewline": false,
4
+ "[python]": {
5
+ "editor.defaultFormatter": "charliermarsh.ruff",
6
+ "editor.formatOnType": true,
7
+ "editor.codeActionsOnSave": {
8
+ "source.fixAll.ruff": "explicit",
9
+ "source.organizeImports": "explicit"
10
+ }
11
+ },
12
+ "[jupyter]": {
13
+ "files.insertFinalNewline": false
14
+ },
15
+ "notebook.output.scrolling": true,
16
+ "notebook.formatOnSave.enabled": true
17
+ }
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import spaces
4
+
5
+
6
+ def on_upload(image: np.ndarray) -> dict:
7
+ return {"image": image}
8
+
9
+
10
+ @spaces.GPU(duration=5)
11
+ def fn(state: dict, evt: gr.SelectData) -> np.ndarray: # noqa: ARG001
12
+ return state["image"]
13
+
14
+
15
+ with gr.Blocks() as demo:
16
+ state = gr.State()
17
+ image = gr.Image()
18
+ out = gr.Image()
19
+
20
+ gr.Examples(
21
+ examples=["cats.jpg"],
22
+ inputs=image,
23
+ fn=on_upload,
24
+ outputs=state,
25
+ run_on_click=True,
26
+ cache_examples=False,
27
+ )
28
+
29
+ image.upload(fn=on_upload, inputs=image, outputs=state)
30
+ image.select(fn=fn, inputs=state, outputs=out)
31
+
32
+ demo.launch()
cats.jpg ADDED

Git LFS Details

  • SHA256: 114e83cc896e9df6476fd682c8d0dc8fafb76e8cf1da5f6396280040081ee1ca
  • Pointer size: 131 Bytes
  • Size of remote file: 681 kB
pyproject.toml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "zerogpu-gr-state"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio>=5.35.0",
9
+ "spaces>=0.37.1",
10
+ ]
11
+
12
+ [tool.ruff]
13
+ line-length = 119
14
+
15
+ [tool.ruff.lint]
16
+ select = ["ALL"]
17
+ ignore = [
18
+ "COM812", # missing-trailing-comma
19
+ "D203", # one-blank-line-before-class
20
+ "D213", # multi-line-summary-second-line
21
+ "E501", # line-too-long
22
+ "SIM117", # multiple-with-statements
23
+ #
24
+ "D100", # undocumented-public-module
25
+ "D101", # undocumented-public-class
26
+ "D102", # undocumented-public-method
27
+ "D103", # undocumented-public-function
28
+ "D104", # undocumented-public-package
29
+ "D105", # undocumented-magic-method
30
+ "D107", # undocumented-public-init
31
+ "EM101", # raw-string-in-exception
32
+ "FBT001", # boolean-type-hint-positional-argument
33
+ "FBT002", # boolean-default-value-positional-argument
34
+ "PD901", # pandas-df-variable-name
35
+ "PGH003", # blanket-type-ignore
36
+ "PLR0913", # too-many-arguments
37
+ "PLR0915", # too-many-statements
38
+ "TRY003", # raise-vanilla-args
39
+ ]
40
+ unfixable = [
41
+ "F401", # unused-import
42
+ ]
43
+
44
+ [tool.ruff.lint.pydocstyle]
45
+ convention = "google"
46
+
47
+ [tool.ruff.lint.per-file-ignores]
48
+ "*.ipynb" = ["T201", "T203"]
49
+
50
+ [tool.ruff.format]
51
+ docstring-code-format = true
uv.lock ADDED
The diff for this file is too large to render. See raw diff