1
0
mirror of https://github.com/tiyn/wiki.git synced 2026-08-25 17:51:37 +02:00

Compare commits

...

12 Commits

Author SHA1 Message Date
ef929292da Presentation: Added pdfpc zooming guide 2026-08-25 14:56:33 +02:00
dfe169870d Presentatin: PDFPC settings added 2026-08-25 13:00:41 +02:00
834487439a Added OSS Dict and Neo Store 2026-08-24 01:16:19 +02:00
cfef5b10ec Merge branch 'master' of github:/tiyn/wiki 2026-08-18 09:41:29 +02:00
4dd67c6c2c Added rembg 2026-08-18 09:41:21 +02:00
ee3d5929bb Programming Languages/Python: Added tensorflow gpu fix 2026-08-18 09:40:47 +02:00
8abca04b9a Adobe Acrobat: Added Setup 2026-07-29 15:34:59 +02:00
41cd91f173 Added eduroam entry 2026-07-23 04:15:57 +02:00
176a23211e Calibre: Added Web Troubleshooting 2026-07-21 00:39:30 +02:00
ac773e4ede Git/uv: Added Git Hooks 2026-07-19 10:26:39 +02:00
1075ec57e3 Python: Added matplotlib troubleshooting for wayland 2026-07-18 18:27:29 +02:00
75372a2220 Linux/Papis: Expanded importing guide 2026-07-18 18:12:45 +02:00
16 changed files with 513 additions and 29 deletions

View File

@@ -4,6 +4,14 @@
[Adobe](https://www.adobe.com/). [Adobe](https://www.adobe.com/).
It is free. It is free.
## Setup
Adobe Acrobat is available for [Windows](/wiki/windows.md), macOS and [Linux](/wiki/linux.md) on the
[official website](https://get.adobe.com/reader/).
For some [Linux distributions](/wiki/linux.md#distributions) — like
[Arch Linux](/wiki/linux/arch-linux.md) there is also a package called `acroread-dc-wine`, which can
be used to set up Adobe Acrobat.
## Usage ## Usage
This section addresses the usage of Adobe Acrobat. This section addresses the usage of Adobe Acrobat.

View File

@@ -0,0 +1,13 @@
# Episteme Reader
[Episteme Reader](https://github.com/Aryan-Raj3112/episteme) is a free and open-source
[e-book](/wiki/e-book.md) reader for [Android](/wiki/android.md).
It supports annotations and OPDS catalogs and can handle large PDF files.
For looking up words while reading, an offline dictionary application such as
[OSS Dict](/wiki/android/oss_dict.md) can be used.
Episteme Reader also features using translation apps like [DeepL](/wiki/deepl.md).
## Setup
On [Android](/wiki/android.md) Episteme Reader is available on [F-Droid](/wiki/android/f-droid.md)
in a package called [Episteme Reader](https://f-droid.org/en/packages/com.aryan.reader.oss/).

View File

@@ -2,6 +2,8 @@
[F-Droid](https://f-droid.org) is an installable catalogue of free and open source [F-Droid](https://f-droid.org) is an installable catalogue of free and open source
software for [Android](/wiki/android.md) systems. software for [Android](/wiki/android.md) systems.
Alternatively, [Neo Store](/wiki/android/neo_store.md) can be used as a modern F-Droid client and
alternative.
## Setup ## Setup

10
wiki/android/neo_store.md Normal file
View File

@@ -0,0 +1,10 @@
# Neo Store
[Neo Store](https://github.com/NeoApplications/Neo-Store) is a free and open-source
[F-Droid](/wiki/android/f-droid.md) client and alternative for [Android](/wiki/android.md).
It can be used to browse, install and update applications from F-Droid and other repositories.
## Setup
On [Android](/wiki/android.md) Neo Store is available on [F-Droid](/wiki/android/f-droid.md) in a
package called [Neo Store](https://f-droid.org/packages/com.machiav3lli.fdroid/).

22
wiki/android/oss_dict.md Normal file
View File

@@ -0,0 +1,22 @@
# OSS Dict
[OSS Dict](https://github.com/fengdeyingzi/OSS-Dict) is a free and open-source offline dictionary
application for [Android](/wiki/android.md) and a fork of Aard 2.
The application can for example be used together with
[Episteme Reader](/wiki/android/episteme_reader.md) for looking up words while reading.
## Setup
On [Android](/wiki/android.md) OSS Dict is available on [F-Droid](/wiki/android/f-droid.md)
in a package called [OSS-Dict](https://f-droid.org/en/packages/com.akylas.aard2/).
## Usage
This section addresses the usage of OSS Dict.
### Installing Dictionaries
Dictionary files have to be downloaded separately and added to OSS Dict.
This is usually done by using `.slob` files.
A guide on where to find them can be found in the
[wiki of the slob Github page](https://github.com/itkach/slob/wiki/Dictionaries).

View File

@@ -154,8 +154,42 @@ This section focuses on the basic usage of calibre's web version.
#### Problems Logging in With Reverse Proxy #### Problems Logging in With Reverse Proxy
It is [a known problem](https://github.com/janeczku/calibre-web/issues/2916?utm_source=chatgpt.com) It is [a known problem](https://github.com/janeczku/calibre-web/issues/2916) not being able to login
not being able to login when using a [reverse proxy](/wiki/reverse-proxy.md) like when using a [reverse proxy](/wiki/reverse-proxy.md) like [Nginx](/wiki/nginx.md) or
[Nginx](/wiki/nginx.md) or [Traefik](/wiki/traefik.md). [Traefik](/wiki/traefik.md).
In this case a 504 error will be displayed. In this case a 504 error will be displayed.
According to various sources this can be fixed by trying previous sections until it works again. According to various sources this can be fixed by trying previous sections until it works again.
#### `sqlite3.OperationalError: no such column: books.isbn`
When starting calibre's web version a `500 Internal Server Error` may be displayed.
The logs contain an error similar to the following.
```txt
sqlite3.OperationalError: no such column: books.isbn
```
This indicates that the `metadata.db` schema is missing the `isbn` and `flags` columns expected by
the installed web version.
As a temporary workaround the missing columns can be added manually using the following command.
The placeholder `<metadata>` is the path to calibre's `metadata.db`.
```sh
sqlite3 <metadata>
```
Afterwards run the following [SQL](/wiki/database.md) commands on the database.
```sql
ALTER TABLE books ADD COLUMN isbn TEXT;
ALTER TABLE books ADD COLUMN flags INTEGER NOT NULL DEFAULT 0;
```
After applying the changes restart the service.
The added columns are metadata fields.
Existing books will keep a `NULL` value for `isbn` and `0` for `flags`.
This workaround allows the web version to start again, however it is recommended to verify that the
library was created with a compatible calibre version and that the correct `metadata.db` is being
used.

14
wiki/deepl.md Normal file
View File

@@ -0,0 +1,14 @@
# DeepL
[DeepL](https://www.deepl.com) is an AI-based translation service for translating text and documents
between various languages.
## Setup
DeepL is a website that can be visited without additional setup needed.
On [Android](/wiki/android.md) DeepL is available on [F-Droid](/wiki/android/f-droid.md) in a
package called [DeepL](https://f-droid.org/en/packages/com.example.deeplviewer/).
Additionally, it is available on the [Google Play store](/wiki/android.md#app-store) in a package
called
[DeepL Translate](https://play.google.com/store/apps/details?id=com.deepl.mobiletranslator&hl=en-US).

View File

@@ -25,18 +25,18 @@ If the software is to be used by you check your local laws first.
## Tracking ## Tracking
Many e-book readers include a feature to keep track of read books. Many e-book readers include a feature to keep track of read books.
However they do not track the time that was needed to finish them or the number of e-books read in However they do not track the time that was needed to finish them or the number of e-books read in
a specific timeframe. a specific timeframe.
This can be done by using a special tracker like [Jelu](/wiki/jelu.md) which can be used to keep This can be done by using a special tracker like [Jelu](/wiki/jelu.md) which can be used to keep
track of e-books and normal books at the same time which is a feature no e-book reader has. track of e-books and normal books at the same time which is a feature no e-book reader has.
## E-Reader ## E-Reader
An e-reader is a device that is designed for reading digital e-books. An e-reader is a device that is designed for reading digital e-books.
Some of them also feature [annotation tools](/wiki/note-taking.md). Some of them also feature [annotation tools](/wiki/note-taking.md).
- [Episteme Reader](https://github.com/Aryan-Raj3112/episteme) is a native - [Episteme Reader](/wiki/android/episteme_reader.md) is a native [Android](/wiki/android.md)
[Android](/wiki/android.md) [e-book](/wiki/e-book.md) reader, that is capable of annotations. e-book reader, that is capable of annotations.
In contrast to [Saber](/wiki/note-taking.md#software) it is able to handle large PDF-files. In contrast to [Saber](/wiki/note-taking.md#software) it is able to handle large PDF-files.
Additionally it features the OPDS protocol for catalogs which can, for example, connect to Additionally it features the OPDS protocol for catalogs which can, for example, connect to
[the OPDS catalog of calibre's web version](/wiki/calibre.md#connect-via-opds). [the OPDS catalog of calibre's web version](/wiki/calibre.md#connect-via-opds).

30
wiki/eduroam.md Normal file
View File

@@ -0,0 +1,30 @@
# eduroam
eduroam, short for education roaming, is a wireless network available at many universities and
research institutions worldwide.
It allows users to connect using the credentials or certificates issued by their home institution.
## Android
The recommended [Android](/wiki/android.md) client is called [geteduroam](https://geteduroam.app/).
It is available on the [Google Play Store](/wiki/android.md#app-store) as well as on
[F-Droid](/wiki/android.md#app-store).
It supports both username/password authentication and certificate-based authentication (EAP-TLS).
Install the application, select your institution and follow the setup process.
The application should remain installed, as removing it also removes the eduroam configuration.
## Linux
Most [Linux](/wiki/linux.md) desktop environments support eduroam directly through
[NetworkManager](/wiki/linux/networkmanager.md).
For username/password authentication configure a new WPA2/WPA3 Enterprise connection using the
parameters provided by your institution.
If certificate-based authentication (EAP-TLS) is used, import the supplied client certificate and
configure the connection accordingly.
The certificate is usually provided by your institution.
Some institutions also provide an installer through the official
[eduroam Configuration Assistant Tool (CAT)](https://cat.eduroam.org).

View File

@@ -98,10 +98,10 @@ The following add-ons provide translation options.
add-on made by Mozilla itself that gives an option for marked text to display its translations add-on made by Mozilla itself that gives an option for marked text to display its translations
quickly from the extension menu but can also translate whole sites. quickly from the extension menu but can also translate whole sites.
- [Simple Translate](https://addons.mozilla.org/en-US/firefox/addon/simple-translate) is an add-on - [Simple Translate](https://addons.mozilla.org/en-US/firefox/addon/simple-translate) is an add-on
supporting both DeepL and Google Translate to translate marked text in various different ways that supporting both [DeepL](/wiki/deepl.md) and Google Translate to translate marked text in various
can be automatically displayed. different ways that can be automatically displayed.
- [To DeepL translation](https://addons.mozilla.org/en-US/firefox/addon/to-deepl/) gives an option - [To DeepL translation](https://addons.mozilla.org/en-US/firefox/addon/to-deepl/) gives an option
for marked text to display its translation in a pop-up window using DeepL. for marked text to display its translation in a pop-up window using [DeepL](/wiki/deepl.md).
#### Shopping Add-ons #### Shopping Add-ons

View File

@@ -1,4 +1,4 @@
# Git (Client) # Git (Package)
This entry deals with the Git client used in [Linux-based systems](/wiki/linux.md). This entry deals with the Git client used in [Linux-based systems](/wiki/linux.md).
For a basic overview and the server setup of git see the For a basic overview and the server setup of git see the
@@ -30,9 +30,57 @@ Robertson also made guides on
[post-production](https://sethrobertson.github.io/GitPostProduction/gpp.html) and a guide on [post-production](https://sethrobertson.github.io/GitPostProduction/gpp.html) and a guide on
[best practices](http://sethrobertson.github.io/GitBestPractices). [best practices](http://sethrobertson.github.io/GitBestPractices).
### Git Hooks
Git Hooks are scripts that are executed automatically when certain Git events occur.
They can be used to run checks, format code or generate files before or after operations such as
commits, merges or pushes.
Hooks are stored in the `.git/hooks` directory of a repository.
They are local to a repository and are not tracked by Git.
A hook has to be marked as executable before it is used.
Common hook names are:
* `applypatch-msg`
* `commit-msg`
* `fsmonitor-watchman`
* `post-applypatch`
* `post-checkout`
* `post-commit`
* `post-merge`
* `post-rewrite`
* `post-update`
* `pre-applypatch`
* `pre-auto-gc`
* `pre-commit`
* `pre-merge-commit`
* `pre-push`
* `pre-rebase`
* `pre-receive`
* `prepare-commit-msg`
* `push-to-checkout`
* `sendemail-validate`
* `update`
The following example prints a short message before every commit.
The script has to be stored in `.git/hooks/pre-commit` and marked as executable.
```sh
chmod +x .git/hooks/pre-commit
```
```sh
#!/bin/sh
echo "Running pre-commit hook..."
```
Other hooks function analog.
### Show Commit Information ### Show Commit Information
To explicitly display all informations corresponding to a given commit hash `<hash>` run the To explicitly display all information corresponding to a given commit hash `<hash>` run the
following command. following command.
```sh ```sh
@@ -55,7 +103,7 @@ git commit --amend --no-edit
``` ```
A graphic that visualizes the way amending works was made by A graphic that visualizes the way amending works was made by
[jubb0bs in a Stackoverflow comment](https://stackoverflow.com/questions/26050327/how-does-git-commit-amend-work-exactly). [jubb0bs in a StackOverflow comment](https://stackoverflow.com/questions/26050327/how-does-git-commit-amend-work-exactly).
After amending a normal `git push` will not work as a commit was removed. After amending a normal `git push` will not work as a commit was removed.
In this case to [push it has to be done forcefully](#force-pushing). In this case to [push it has to be done forcefully](#force-pushing).
@@ -113,11 +161,10 @@ git ls-files -v | grep "^S"
Authentication by default is done via a username and a password. Authentication by default is done via a username and a password.
For some services such as GitHub. For some services such as GitHub.
it is not possible to use password as an authentication method. It is not possible to use password as an authentication method.
The other possibility to authenticate to git is by using [SSH](/wiki/ssh.md). The other possibility to authenticate to git is by using [SSH](/wiki/ssh.md).
The following sections assumes using a [Linux-based system](/wiki/linux.md) using The following sections assumes [Linux](/wiki/linux.md) is using [OpenSSH](/wiki/linux/openssh.md).
[OpenSSH](/wiki/linux/openssh.md).
For this a For this a
[SSH certificate has to be created](/wiki/linux/openssh.md#generate-new-keys) and [SSH certificate has to be created](/wiki/linux/openssh.md#generate-new-keys) and
[added to the authentication agent](/wiki/linux/openssh.md#adding-keys-to-authentication-agent). [added to the authentication agent](/wiki/linux/openssh.md#adding-keys-to-authentication-agent).
@@ -147,7 +194,7 @@ There are different possibilities to improve the diff of git.
One of them is [diff-so-fancy](#git-diff-diff-so-fancy) which allows word specific `git diff`. One of them is [diff-so-fancy](#git-diff-diff-so-fancy) which allows word specific `git diff`.
A second and more modern option is [delta](#git-diff-delta) which additionally allows syntax A second and more modern option is [delta](#git-diff-delta) which additionally allows syntax
highlighting and a side-by-side view. highlighting and a side-by-side view.
delta also improves the `git blame` command, which is another reason why it is widely more popular Delta also improves the `git blame` command, which is another reason why it is widely more popular
then diff-so-fancy. then diff-so-fancy.
A more or less complete overview of the options was performed in an A more or less complete overview of the options was performed in an
@@ -180,8 +227,8 @@ Depending on the system settings and preferences the dark-mode (`dark`) and the
#### `git diff`: diff-so-fancy #### `git diff`: diff-so-fancy
[diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) is a drop in replacement for the default The package [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) is a drop-in replacement for
`git diff` look. the default `git diff` look.
It can be installed via most [package managers](/wiki/linux/package_manager.md) using the It can be installed via most [package managers](/wiki/linux/package_manager.md) using the
`diff-so-fancy` package. `diff-so-fancy` package.
Afterward the following lines need to be run to complete the configuration. Afterward the following lines need to be run to complete the configuration.

View File

@@ -9,7 +9,7 @@ for [LaTeX](/wiki/markup_language.md#latex) using the BibTeX format.
Papis can be installed on most [Linux](/wiki/linux.md) distributions by acquiring the `papis` Papis can be installed on most [Linux](/wiki/linux.md) distributions by acquiring the `papis`
package. package.
On some distributions there may be problems installing this from the official repository. On some distributions there may be problems installing this from the official repository.
Another option to install papis is to use [pip](/wiki/programming_language/python.md). Another option to install Papis is to use [pip](/wiki/programming_language/python.md).
Alternatively it can be downloaded from [the GitHub page](https://github.com/papis/papis). Alternatively it can be downloaded from [the GitHub page](https://github.com/papis/papis).
### Configuration ### Configuration
@@ -17,7 +17,7 @@ Alternatively it can be downloaded from [the GitHub page](https://github.com/pap
To use Papis a config file needs to be created. To use Papis a config file needs to be created.
The path of the global config file is `~/.config/papis/config`. The path of the global config file is `~/.config/papis/config`.
A minimal config can look like the following. A minimal config can look like the following.
Make sure to change the path of the papers directory. Make sure to change the path to the directory of the paper.
```txt ```txt
[papers] [papers]
@@ -128,8 +128,8 @@ Afterward the contents of the temporary database should be checked to be correct
papis -l tmp-db edit papis -l tmp-db edit
``` ```
Afterward the contents of the temporary library should be moved to the actualy directory where Afterward the contents of the temporary library should be moved to the actual directory where Papis
papis stores its entries. stores its entries.
The path for that can be found in the [config file](#configuration). The path for that can be found in the [config file](#configuration).
```sh ```sh
@@ -140,6 +140,13 @@ Finally, the cache needs to be cleared
[as described in the corresponding section](#clearing-the-cache) for Papis to display the new [as described in the corresponding section](#clearing-the-cache) for Papis to display the new
entries correctly. entries correctly.
Alternatively the BibTeX file can instantly be imported using the following command where `<file>`
is a placeholder for the BibTeX file.
```sh
papis bibtex read <file> import --all
```
### Changing the Default Names of the Library ### Changing the Default Names of the Library
The changing of the default names is done by changing the [config file](#configuration). The changing of the default names is done by changing the [config file](#configuration).

View File

@@ -24,3 +24,7 @@ The following is a list of these tools.
Basic guides for this can be found on the pages of Basic guides for this can be found on the pages of
[toromtomtom](https://www.toromtomtom.com/blog/2021/10/17/pdfpc.html) and [toromtomtom](https://www.toromtomtom.com/blog/2021/10/17/pdfpc.html) and
[Utah university](https://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/pdfpc/pdfpc-doc.pdf). [Utah university](https://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/pdfpc/pdfpc-doc.pdf).
Most importantly the tab key opens the overview mode, `p` pauses, `f` freezes, `t` opens
clickable options, `g` opens the option to navigate to a specific page, `h` hides and `b` shows
`a` blank foil. After selecting a rectangular space with the pointer tool, `z` can be pressed to
zoom into it.

View File

@@ -29,8 +29,8 @@ to your `~/.profile`.
You can then set and install your preferred version of python globally with You can then set and install your preferred version of python globally with
`pyenv install <version>` and `pyenv global <version>`. `pyenv install <version>` and `pyenv global <version>`.
Analog to managing python versions, `pipenv` can manage Analog to managing python versions, `pipenv` can manage [pip](#pip) and
[pip](/wiki/programming_language/python/uv.md) and package versions. [package versions](#package-management).
A guide and description of the usage can be found on [gioele.io](https://gioele.io/pyenv-pipenv). A guide and description of the usage can be found on [gioele.io](https://gioele.io/pyenv-pipenv).
### Manual Installation ### Manual Installation
@@ -95,7 +95,7 @@ itself every time.
For general information about shebangs, executable scripts and the `chmod +x` command, refer to the For general information about shebangs, executable scripts and the `chmod +x` command, refer to the
corresponding section in the [Shell article](/wiki/linux/shell.md#shebangs). corresponding section in the [Shell article](/wiki/linux/shell.md#shebangs).
For Python it is recommended to use the following shebang. For Python, it is recommended to use the following shebang.
```py ```py
#!/usr/bin/env python #!/usr/bin/env python
@@ -150,6 +150,7 @@ A more modern and arguably better approach is using
#### venv Virtual Environments #### venv Virtual Environments
[venv](https://docs.python.org/3/library/venv.html) can be used to create a virtual environment. [venv](https://docs.python.org/3/library/venv.html) can be used to create a virtual environment.
It usually uses the standard [pip](#pip) manager for installing libraries.
``` ```
python -m venv <project-path> python -m venv <project-path>
@@ -184,6 +185,61 @@ ln -s <local-venv> ~/.pyenv/versions/<venv-name>
Using this setup the python version will automatically change when navigating into the project Using this setup the python version will automatically change when navigating into the project
directory. directory.
## Package Management
Python packages can be installed using package managers.
For new projects it is generally recommended to use [uv](#uv), while [pip](#pip) is available by
default in most Python installations and is supported by virtually all Python projects.
### pip
The `pip` package manager is the standard Python package manager and can be used to install, upgrade
and remove Python packages.
It is recommended to use `pip` inside a [virtual environment](#using-virtual-environments).
A package called `<package>` can be installed using
```sh
pip install <package>
```
To upgrade an already installed package run
```sh
pip install --upgrade <package>
```
Packages can be removed again using
```sh
pip uninstall <package>
```
To display all currently installed packages use
```sh
pip list
```
### uv
For new projects it is generally recommended to use [uv](/wiki/programming_language/python/uv.md),
which provides a modern replacement for [pip](#pip), [venv](#venv-virtual-environments) and several
other Python tools.
The corresponding article describes installation, virtual environments, dependency management and
further usage in detail.
## Modules
Python modules can be installed using package managers such as
[pip](/wiki/programming_language/python/pip.md) or
[uv](/wiki/programming_language/python/uv.md).
For most projects it is recommended to use a
[virtual environment](#using-virtual-environments).
For global installation the
[system package managers](/wiki/linux/package_manager.md) can be used.
## Modules ## Modules
Python modules can be installed using package managers such as Python modules can be installed using package managers such as
@@ -222,10 +278,10 @@ Afterward all possible scikit-learn algorithms will run on the GPU instead of th
### PyTorch ### PyTorch
This section addresses the [PyTorch module](https://pytorch.org/). This section addresses the [PyTorch module](https://pytorch.org/).
Pytorch is a machine learning resource which is often used for PyTorch is a machine learning resource which is often used for
[neural networks](/wiki/neural_network.md). [neural networks](/wiki/neural_network.md).
#### Setup Pytorch with CUDA for GPU usage #### Setup PyTorch with CUDA for GPU usage
CUDA is also only available for Nvidia GPUs. CUDA is also only available for Nvidia GPUs.
For AMD GPUs refer to [the ROCm section](#setup-pytorch-with-rocm-for-gpu-usage). For AMD GPUs refer to [the ROCm section](#setup-pytorch-with-rocm-for-gpu-usage).
@@ -325,7 +381,7 @@ can be referenced.
### TensorFlow ### TensorFlow
This section addresses the [TensorFlow module](https://www.tensorflow.org/). This section addresses the [TensorFlow module](https://www.tensorflow.org/).
Tensorflos is a machine learning resource which is often used for TensorFlow is a machine learning resource which is often used for
[neural networks](/wiki/neural_network.md). [neural networks](/wiki/neural_network.md).
Apart from [package managers](/wiki/linux/package_manager.md) and Apart from [package managers](/wiki/linux/package_manager.md) and
@@ -334,6 +390,88 @@ on [the official website](https://www.tensorflow.org/install/source).
This may especially be useful if specific configurations are needed such as vendor specific GPU This may especially be useful if specific configurations are needed such as vendor specific GPU
support. support.
#### Setup TensorFlow with CUDA in a uv Project
TensorFlow can install its required CUDA user-space libraries as optional dependencies on Linux.
The NVIDIA driver still has to be installed on the host system.
```sh
nvidia-smi
uv add 'tensorflow[and-cuda]'
```
Verify whether TensorFlow was built with CUDA support and detects the GPU.
```sh
uv run python -c 'import tensorflow as tf; print("CUDA build:", tf.test.is_built_with_cuda()); print(tf.config.list_physical_devices("GPU"))'
```
If `CUDA build` is `True` but no GPU is listed and TensorFlow reports that it cannot load GPU
libraries, the dynamic linker may not find the NVIDIA libraries installed inside the virtual
environment.
The following command temporarily adds all library directories from the installed `nvidia-*`
packages.
```sh
SITE_PACKAGES=$(uv run python -c 'import site; print(site.getsitepackages()[0])')
CUDA_LIBS=$(find "$SITE_PACKAGES/nvidia" -type d -name lib -printf '%p:')
LD_LIBRARY_PATH="${CUDA_LIBS}/usr/lib" uv run python -c \
'import tensorflow as tf; print(tf.config.list_physical_devices("GPU"))'
```
If the test succeeds, store the path in a machine-specific dotenv file.
```sh
printf 'LD_LIBRARY_PATH=%s/usr/lib\n' "$CUDA_LIBS" > .env.cuda
printf '.env.cuda\n' >> .gitignore
```
Run the project with the file explicitly.
```sh
uv run --env-file .env.cuda python <script>.py
```
To load it automatically, create a `.envrc` file and use
[direnv](https://direnv.net/).
```sh
printf 'export UV_ENV_FILE="$PWD/.env.cuda"\n' > .envrc
eval "$(direnv hook zsh)"
direnv allow
```
For more information about dotenv files in uv, refer to the
[uv environment variable section](/wiki/programming_language/python/uv.md#loading-environment-variables).
Some recent GPUs may require CUDA kernels to be compiled from PTX on the first run because the
TensorFlow wheel does not yet contain native kernel binaries for their compute capability.
For example, TensorFlow 2.21 reports this for an RTX 5060 Ti with compute capability `12.0a`.
According to NVIDIA's
[explanation of PTX compatibility](https://developer.nvidia.com/blog/understanding-ptx-the-assembly-language-of-cuda-gpu-computing/),
embedded PTX can be compiled for newer GPU generations at runtime.
The first start can therefore take considerably longer, while the resulting binary is normally
cached for subsequent runs.
Make sure the `ptxas` executable installed by the CUDA dependency is available in the virtual
environment.
```sh
VENV_DIR=$(uv run python -c 'import sys; print(sys.prefix)')
PTXAS=$(find "$VENV_DIR" -type f -name ptxas -print -quit)
ln -sf "$PTXAS" "$VENV_DIR/bin/ptxas"
```
The library lookup problem is not caused by the GPU being new; it is an environment configuration
issue.
The new GPU generation only explains why TensorFlow falls back to PTX JIT compilation after the
libraries have been found.
Refer to the
[official TensorFlow installation guide](https://www.tensorflow.org/install/pip) for the current
CUDA installation and troubleshooting steps.
#### Basic Usage of TensorFlow #### Basic Usage of TensorFlow
The basic usage of TensorFlow is described in The basic usage of TensorFlow is described in
@@ -358,3 +496,31 @@ A simple example for the combination of two models (`model1` and `model2`) into
output = model2(model1.output) output = model2(model1.output)
combined_model = tf.keras.models.Model(inputs=model1.input, outputs=output) combined_model = tf.keras.models.Model(inputs=model1.input, outputs=output)
``` ```
### matplotlib
The [matplotlib](https://matplotlib.org/) module is a plotting library for Python.
#### Qt Backend Not Found
When using [Wayland](/wiki/linux/wayland.md), matplotlib may fail with an error similar to the
following.
```txt
ImportError: Failed to import any of the following Qt binding modules:
PyQt6, PySide6, PyQt5, PySide2
```
This happens because matplotlib uses the Qt backend (`QtAgg`) for displaying interactive windows,
but no Qt Python bindings are installed.
To fix the issue simply install `PyQt6` inside the current
[Python environment](#using-virtual-environments).
This may look like the following example where [uv](/wiki/programming_language/python/uv.md) is
used but other environments such as [pip](#pip) can also be used.
```sh
uv add PyQt6
```
After installing `PyQt6`, interactive matplotlib windows should work correctly under Wayland.

View File

@@ -14,6 +14,50 @@ to install uv on your operating system.
This section addresses the usage of uv. This section addresses the usage of uv.
### Automatically Updating `requirements.txt`
Projects that still require a `requirements.txt` file can regenerate it automatically by using a Git
`pre-commit` hook.
The hook is executed before every commit and can export the current project dependencies before the
changes are committed.
For the export command see the
[`requirements.txt` export section](#exporting-requirementstxt).
For a general explanation of Git hooks refer to the
[Git Hooks section](/wiki/linux/git_%28package%29.md#git-hooks) in the
[Git package entry](/wiki/linux/git_%28package%29.md).
### Exporting `requirements.txt`
Although `uv` primarily manages dependencies through `pyproject.toml` and `uv.lock`, some tools like
[pip](/wiki/programming_language/python.md#pip) and other
[virtual environments](/wiki/programming_language/python.md#using-virtual-environments) still expect
a `requirements.txt` file.
The recommended way to generate it is by exporting the locked project dependencies.
```sh
uv export --format requirements-txt -o requirements.txt
```
This creates a reproducible `requirements.txt` based on the project's lock file.
Alternatively, the packages currently installed in the active virtual environment can be exported.
```sh
uv pip freeze > requirements.txt
```
Unlike `uv export`, this command only lists the packages that are currently installed and therefore
depends on the state of the active environment.
If a `requirements.txt` file should always stay in sync with the project dependencies, it can be
automatically regenerated using a Git `pre-commit` hook.
For more information refer to the
[Git Hooks section](/wiki/linux/git_%28package%29.md#git-hooks) in
[Linux' entry about Git](/wiki/linux/git_%28package%29.md).
### Executable Scripts ### Executable Scripts
uv fully supports Python scripts that use the standard Python shebang. uv fully supports Python scripts that use the standard Python shebang.
@@ -69,6 +113,44 @@ desired package.
uv add <package> uv add <package>
``` ```
### Loading Environment Variables
[`uv run`](https://docs.astral.sh/uv/concepts/configuration-files/#environment-variable-files) can
load environment variables from dotenv files.
Use `--env-file` to load a file for one command.
```sh
uv run --env-file .env.local python <script>.py
```
Alternatively, set `UV_ENV_FILE` to use the same file for subsequent `uv run` commands in the
current shell.
```sh
export UV_ENV_FILE="$PWD/.env.local"
uv run python <script>.py
```
For project-local automation, [direnv](https://direnv.net/) can set `UV_ENV_FILE` whenever the
project directory is entered.
Create `.envrc` in the project root with the following content.
```sh
export UV_ENV_FILE="$PWD/.env.local"
```
Enable the shell hook, then approve the file.
The example uses Zsh.
```sh
eval "$(direnv hook zsh)"
direnv allow
```
The shell hook should be added to `~/.zshrc` to enable it in new shells.
`direnv allow` always expects a `.envrc`; it does not load `.env.local` directly.
Machine-specific dotenv files should usually be added to `.gitignore`.
### Installing CLI Tools ### Installing CLI Tools
Besides managing projects and virtual environments, `uv` can also install Besides managing projects and virtual environments, `uv` can also install

45
wiki/rembg.md Normal file
View File

@@ -0,0 +1,45 @@
# rembg
[rembg](https://github.com/danielgatis/rembg) is a [command line](/wiki/linux/shell.md) tool and
Python library for removing image backgrounds using pretrained
[neural networks](/wiki/neural_network.md) executed through ONNX Runtime.
## Setup
rembg can be installed from source as described on the
[official GitHub repository](https://github.com/danielgatis/rembg).
Alternatively a [Python package manager](/wiki/programming_language/python.md#package-management)
can be used to install rembg.
For the backend one must select CPU or GPU usage.
For command line usage an extra package has to be installed in addition to the inference backend.
Depending on that choice the name of the package will be `"rembg[cpu,cli]"` or `rembg[gpu,cli]`.
## Usage
This section addresses the usage of rembg.
### Remove Background
The following command removes the background from an image using a specific `<model>`.
In this case `<input>` is a placeholder for the input image path and `<output>` for the output image
path.
```sh
rembg i -m <model> <input> <output>
```
Depending on the use-case other models may also be used.
`u2net` is a general purpose model and most of the time a good default.
`u2net_human_seg` is optimized for human subjects.
`isnet-general-use` is an alternative general-purpose model.
The quality depends on the selected model and the input image.
For portraits with complex backgrounds such as bushes or trees, `u2net` often produces the best
overall results, while other models may perform better on different types of images.
Additionally, alpha matting can improve difficult edges such as hair.
```sh
rembg i -m <model> -a <input> <output>
```