Commit Graph

8605 Commits

Author SHA1 Message Date
psychedelicious
909b78a1cb fix(ui): fix missing images not handled
- Reset init image, control adapter images, and node image fields when their selected image fails to load
- Only do this if the app is connected via socket (this indicates that the image is "really" gone, and there isn't just a transient network issue)

It's possible for image parameters/nodes/states to have reference a deleted image. For example, a resize image node might have an image set on it, and the workflow saved. The workflow contains a hard reference to that image.

The image is deleted and the workflow loaded again later. The deleted image is still in that workflow, but the app doesn't detect that. The result is that the workflow/graph appears to be valid, but will fail on invoke.

This creates a really confusing user experience, where when somebody shares a workflow with an image baked into it, and another person opens it, everything *looks* ok, but the workflow fails with a mysterious error about a missing image.

The problem affects node images, control adapter images and the img2img init image. Resetting the image when it fails to load *and* socket is connected resolves this in a simple way.

The problem also affects canvas images, but we have handle that by displaying an error fallback image, so no change is made there.
2023-12-01 00:35:06 +11:00
psychedelicious
2f81f9fb22 fix(ui): add missing star image translation key 2023-12-01 00:33:04 +11:00
psychedelicious
a6d4e4ed57 fix(ui): fix enum parsing for optional enums
Closes #5121

- Parse `anyOf` for enums (present when they are optional)
- Consolidate `FieldTypeParseError` and `UnsupportedFieldTypeError` into `FieldParseError` (there was no difference in handling and it simplifies things a bit)
2023-11-30 05:01:29 -08:00
ymgenesis
3e01c396e1
CenterPadCrop node (#3861)
* add centerpadcrop node

- Allows users to add padding to or crop images from the center
- Also outputs a white mask with the dimensions of the output image for use with outpainting

* add CenterPadCrop to NODES.md

Updates NODES.md with CenterPadCrop entry.

* remove mask & output class

- Remove "ImageMaskOutput" where both image and mask are output
- Remove ability to output mask from node

---------

Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
2023-11-30 21:15:59 +11:00
Damian Stewart
0beb08686c
Add CFG Rescale option for supporting zero-terminal SNR models (#4335)
* add support for CFG rescale

* fix typo

* move rescale position and tweak docs

* move input position

* implement suggestions from github and discord

* cleanup unused code

* add back dropped FieldDescription

* fix(ui): revert unrelated UI changes

* chore(nodes): bump denoise_latents version 1.4.0 -> 1.5.0

* feat(nodes): add cfg_rescale_multiplier to metadata node

* feat(ui): add cfg rescale multiplier to linear UI

- add param to state
- update graph builders
- add UI under advanced
- add metadata handling & recall
- regen types

* chore: black

* fix(backend): make `StableDiffusionGeneratorPipeline._rescale_cfg()` staticmethod

This doesn't need access to class.

* feat(backend): add docstring for `_rescale_cfg()` method

* feat(ui): update cfg rescale mult translation string

---------

Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
2023-11-30 20:55:20 +11:00
Ryan Dick
693c6cf5e4 Add support for IPAdapterFull models. The changes are based on this upstream PR: https://github.com/tencent-ailab/IP-Adapter/pull/139 . 2023-11-29 15:07:21 -08:00
skunkworxdark
77933a0a85 Update prompt.py
bumped version to 1.0.1
2023-11-29 23:40:10 +11:00
skunkworxdark
2a087bf161 Update prompt.py
Use UTF-8 encoding on reading prompts from files to allow Unicode characters to load correctly. 
The following examples currently will not load correctly from a file:

Hello, 世界!
😭🤮 💔
2023-11-29 23:40:10 +11:00
Millun Atluri
b0fe57ec80
Update communityNodes.md (#5184)
Added New Match Histogram node
Updated XYGrid nodes and Prompt Tools nodes

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [ ] Optimization
- [x] Documentation Update
- [ ] Community Node Submission


## Have you discussed this change with the InvokeAI team?
- [ ] Yes
- [ ] No, because:

      
## Have you updated all relevant documentation?
- [ ] Yes
- [ ] No


## Description


## Related Tickets & Documents

<!--
For pull requests that relate or close an issue, please include them
below. 

For example having the text: "closes #1234" would connect the current
pull
request to issue 1234.  And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #

## QA Instructions, Screenshots, Recordings

<!-- 
Please provide steps on how to test changes, any hardware or 
software specifications as well as any other pertinent information. 
-->

## Added/updated tests?

- [ ] Yes
- [ ] No : _please replace this line with details on why tests
      have not been included_

## [optional] Are there any post deployment tasks we need to perform?
2023-11-29 14:10:26 +11:00
Millun Atluri
09cb40786f
(fix) Update communityNodes.md installation instructions
Update custom node instructions to be clearer
2023-11-29 14:08:50 +11:00
Millun Atluri
18ecfc0521
Merge branch 'main' into patch-2 2023-11-29 14:07:13 +11:00
psychedelicious
59d932e9c1 chore(ui): lint 2023-11-29 11:06:07 +11:00
psychedelicious
578c8ce5dd feat(ui): enforce absolute import paths
- add & configure `eslint-plug-path`
2023-11-29 11:06:07 +11:00
psychedelicious
3d4874dc34 feat(ui): "Polymorphic" -> "CollectionOrScalar"
This new name more accurately represents that these are fields with a type of `T | T[]`, where the "base" type must be the same on both sides of the union.
2023-11-29 10:49:31 +11:00
psychedelicious
5aaf2e8873 fix(ui): fix typing of FIELD_VALUE_FALLBACK_MAP 2023-11-29 10:49:31 +11:00
psychedelicious
f3fd0f6d73 fix(ui): remove unused schema/type/guard 2023-11-29 10:49:31 +11:00
psychedelicious
4468581d2e fix(nodes): remove extraneous del 2023-11-29 10:49:31 +11:00
psychedelicious
da642b7aad feat(ui): update comments in field.ts 2023-11-29 10:49:31 +11:00
psychedelicious
b379e3d187 fix(ui): fix capitalization 2023-11-29 10:49:31 +11:00
psychedelicious
6867c79185 fix(tests): remove deprecated arg 2023-11-29 10:49:31 +11:00
psychedelicious
a1705dc6b3 fix(nodes): fix loading node pack display 2023-11-29 10:49:31 +11:00
psychedelicious
4af4486dd9 feat(nodes,ui): add detection of custom nodes
Custom nodes have a new attribute `node_pack` indicating the node pack they came from.

- This is displayed in the UI in the icon icon tooltip.
- If a workflow is loaded and a node is unavailable, its node pack will be displayed (if it is known).
- If a workflow is migrated from v1 to v2, and the node is unknown, it falls back to "Unknown". If the missing node pack is installed and the node is updated, the node pack will be updated as expected.
2023-11-29 10:49:31 +11:00
psychedelicious
282a7f32d3 feat(ui): improve openapi schema types
We can use the autogenerated types to avoid types
2023-11-29 10:49:31 +11:00
psychedelicious
4c6a88a642 feat(ui): update readme 2023-11-29 10:49:31 +11:00
psychedelicious
e41d0b9a76 feat(ui): add links to relevant files in workflows doc 2023-11-29 10:49:31 +11:00
psychedelicious
a02090b06b feat(ui): update workflows design & implementation docs 2023-11-29 10:49:31 +11:00
psychedelicious
0d9a546d74 feat(ui): organize migrations files 2023-11-29 10:49:31 +11:00
psychedelicious
8d99113bef feat(ui): organize node utils 2023-11-29 10:49:31 +11:00
psychedelicious
4309f3bd58 feat(ui): tidy node-related types 2023-11-29 10:49:31 +11:00
psychedelicious
42370939a8 feat(ui): update workflows design & implementation docs (wip) 2023-11-29 10:49:31 +11:00
psychedelicious
654591cbf3 feat(ui): make buildFieldInputTemplate arg name consistent 2023-11-29 10:49:31 +11:00
psychedelicious
ad9c954a58 feat(ui): move field output template builder to own file 2023-11-29 10:49:31 +11:00
psychedelicious
a703e1b3d3 feat(ui): add errors for invalid polymorphic types 2023-11-29 10:49:31 +11:00
psychedelicious
e85f2254f0 feat(ui): update fields docstring 2023-11-29 10:49:31 +11:00
psychedelicious
8f2cf30191 feat(ui): add workflows design & implementation doc (WIP) 2023-11-29 10:49:31 +11:00
psychedelicious
296741306c feat(ui): update frontend README 2023-11-29 10:49:31 +11:00
psychedelicious
5386a286fd feat(ui): constrain w/h in imageoutput schema 2023-11-29 10:49:31 +11:00
psychedelicious
803fb393bb fix(ui): fix mis-named typeguard 2023-11-29 10:49:31 +11:00
psychedelicious
ab944bd13a feat(ui): remove docs/ from prettierignore 2023-11-29 10:49:31 +11:00
psychedelicious
514c49d946 feat(nodes): warn if node has no version specified; fall back on 1.0.0 2023-11-29 10:49:31 +11:00
psychedelicious
858bcdd3ff feat(nodes): improve docstrings in baseinvocation, disambiguate method names 2023-11-29 10:49:31 +11:00
psychedelicious
ed79980dd4 feat(ui): improved UI for missing node field templates
When a node is updated with new fields and workflow needs to be updated, the fields now display "Unknown input/output: FieldName".
2023-11-29 10:49:31 +11:00
psychedelicious
86a74e929a feat(ui): add support for custom field types
Node authors may now create their own arbitrary/custom field types. Any pydantic model is supported.

Two notes:
1. Your field type's class name must be unique.

Suggest prefixing fields with something related to the node pack as a kind of namespace.

2. Custom field types function as connection-only fields.

For example, if your custom field has string attributes, you will not get a text input for that attribute when you give a node a field with your custom type.

This is the same behaviour as other complex fields that don't have custom UIs in the workflow editor - like, say, a string collection.

feat(ui): fix tooltips for custom types

We need to hold onto the original type of the field so they don't all just show up as "Unknown".

fix(ui): fix ts error with custom fields

feat(ui): custom field types connection validation

In the initial commit, a custom field's original type was added to the *field templates* only as `originalType`. Custom fields' `type` property was `"Custom"`*. This allowed for type safety throughout the UI logic.

*Actually, it was `"Unknown"`, but I changed it to custom for clarity.

Connection validation logic, however, uses the *field instance* of the node/field. Like the templates, *field instances* with custom types have their `type` set to `"Custom"`, but they didn't have an `originalType` property. As a result, all custom fields could be connected to all other custom fields.

To resolve this, we need to add `originalType` to the *field instances*, then switch the validation logic to use this instead of `type`.

This ended up needing a bit of fanagling:

- If we make `originalType` a required property on field instances, existing workflows will break during connection validation, because they won't have this property. We'd need a new layer of logic to migrate the workflows, adding the new `originalType` property.

While this layer is probably needed anyways, typing `originalType` as optional is much simpler. Workflow migration logic can come layer.

(Technically, we could remove all references to field types from the workflow files, and let the templates hold all this information. This feels like a significant change and I'm reluctant to do it now.)

- Because `originalType` is optional, anywhere we care about the type of a field, we need to use it over `type`. So there are a number of `field.originalType ?? field.type` expressions. This is a bit of a gotcha, we'll need to remember this in the future.

- We use `Array.prototype.includes()` often in the workflow editor, e.g. `COLLECTION_TYPES.includes(type)`. In these cases, the const array is of type `FieldType[]`, and `type` is is `FieldType`.

Because we now support custom types, the arg `type` is now widened from `FieldType` to `string`.

This causes a TS error. This behaviour is somewhat controversial (see https://github.com/microsoft/TypeScript/issues/14520). These expressions are now rewritten as `COLLECTION_TYPES.some((t) => t === type)` to satisfy TS. It's logically equivalent.

fix(ui): typo

feat(ui): add CustomCollection and CustomPolymorphic field types

feat(ui): add validation for CustomCollection & CustomPolymorphic types

- Update connection validation for custom types
- Use simple string parsing to determine if a field is a collection or polymorphic type.
- No longer need to keep a list of collection and polymorphic types.
- Added runtime checks in `baseinvocation.py` to ensure no fields are named in such a way that it could mess up the new parsing

chore(ui): remove errant console.log

fix(ui): rename 'nodes.currentConnectionFieldType' -> 'nodes.connectionStartFieldType'

This was confusingly named and kept tripping me up. Renamed to be consistent with the `reactflow` `ConnectionStartParams` type.

fix(ui): fix ts error

feat(nodes): add runtime check for custom field names

"Custom", "CustomCollection" and "CustomPolymorphic" are reserved field names.

chore(ui): add TODO for revising field type names

wip refactor fieldtype structured

wip refactor field types

wip refactor types

wip refactor types

fix node layout

refactor field types

chore: mypy

organisation

organisation

organisation

fix(nodes): fix field orig_required, field_kind and input statuses

feat(nodes): remove broken implementation of default_factory on InputField

Use of this could break connection validation due to the difference in node schemas required fields and invoke() required args.

Removed entirely for now. It wasn't ever actually used by the system, because all graphs always had values provided for fields where default_factory was used.

Also, pydantic is smart enough to not reuse the same object when specifying a default value - it clones the object first. So, the common pattern of `default_factory=list` is extraneous. It can just be `default=[]`.

fix(nodes): fix InputField name validation

workflow validation

validation

chore: ruff

feat(nodes): fix up baseinvocation comments

fix(ui): improve typing & logic of buildFieldInputTemplate

improved error handling in parseFieldType

fix: back compat for deprecated default_factory and UIType

feat(nodes): do not show node packs loaded log if none loaded

chore(ui): typegen
2023-11-29 10:49:31 +11:00
Alexander Eichhorn
0d52430481 move toast to the bottom right 2023-11-29 09:51:56 +11:00
Mary Hipp Rogers
4eca802cdd
fix preselected image (#5185)
* fix for new response shape

* unused import

---------

Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
2023-11-28 09:24:54 -05:00
skunkworxdark
ff0a25bd9c
Update communityNodes.md
Added New Match Histogram node
Updated XYGrid nodes and Prompt Tools nodes
2023-11-28 12:07:29 +00:00
Lincoln Stein
ace0eb366b pin opencv-python to get required cv2.typing module 2023-11-28 16:36:37 +11:00
Lincoln Stein
d971c5fa64 remove the logging and config modules from the mypy ignore list 2023-11-28 09:38:35 +11:00
Lincoln Stein
ae82df0fda fix a bunch of type mismatches in the logging module 2023-11-28 09:38:35 +11:00
psychedelicious
e28262ebd9 fix(config): use public import path for JsonDict 2023-11-28 09:30:49 +11:00