Skip to content

Commit

Permalink
HOTFIX V0.2.7
Browse files Browse the repository at this point in the history
renames validate to validate_synapse
fixes comfy miner to not use internal synapse.validate()
  • Loading branch information
CreativeBuilds committed Oct 7, 2023
1 parent b4184e0 commit 08ad544
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.6
0.2.7
4 changes: 2 additions & 2 deletions miners/comfy/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from utils import StableDiffusionSafetyChecker
from transformers import CLIPImageProcessor
import torchvision.transforms as transforms
from protocol import TextToImage, ImageToImage
from protocol import TextToImage, ImageToImage, validate_synapse

from generate import t2i, i2i

Expand Down Expand Up @@ -188,7 +188,7 @@ async def forward_t2i( synapse: TextToImage ) -> TextToImage:
synapse.images.append( bt.Tensor.serialize( img_tensor ) )

# validate the synapse
valid, error = synapse.validate()
valid, error = validate_synapse(synapse)
if not valid:
raise ValueError(f"Invalid synapse: {error}")

Expand Down
10 changes: 5 additions & 5 deletions protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import bittensor as bt
from typing import Literal

def validate( synapse ) -> (bool, str):
def validate_synapse( synapse ) -> (bool, str):
# check tensor type first
if not all( [ isinstance(image, bt.Tensor) for image in synapse.images ] ):
return False, "images are not tensors"
return (False, "images are not tensors")
# check number of images
if len(synapse.images) != synapse.num_images_per_prompt:
return False, "number of images does not match num_images_per_prompt"
return (False, "number of images does not match num_images_per_prompt")
# check image size
if not all( [ image.shape[1] == synapse.height and image.shape[2] == synapse.width for image in synapse.images ] ):
return False, "image size does not match height and width"
return (False, "image size does not match height and width")
# if all checks pass, return True, ""
return True, ""
return (True, "")

class TextToImage( bt.Synapse ):
images: list[ bt.Tensor ] = []
Expand Down
4 changes: 2 additions & 2 deletions validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
current_script_dir = os.path.dirname(os.path.realpath(__file__))
parent_dir = os.path.dirname(current_script_dir)
sys.path.append(parent_dir)
from protocol import TextToImage, validate
from protocol import TextToImage, validate_synapse

# Load the config.
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -431,7 +431,7 @@ async def main():

# validate all responses, if they fail validation remove both the response from responses and dendrites_to_query
for i, response in enumerate(responses):
valid, error = validate(response)
valid, error = validate_synapse(response)
if not valid:
bt.logging.trace(f"Detected invalid response from dendrite {dendrites_to_query[i]}: {error}")
del responses[i]
Expand Down

0 comments on commit 08ad544

Please sign in to comment.