Skip to content

Commit

Permalink
Merge branch 'main' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanuys committed Oct 16, 2024
2 parents 2ba7fd8 + 24b4769 commit 57f4599
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bitmind/validator/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ async def forward(self):
responses = await self.dendrite(
axons=axons,
synapse=prepare_image_synapse(image=image),
deserialize=True
deserialize=True,
timeout=9
)

# update logging data
Expand Down
20 changes: 17 additions & 3 deletions neurons/validator_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from starlette.concurrency import run_in_threadpool
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from cryptography.exceptions import InvalidSignature
from PIL import Image
from io import BytesIO
import bittensor as bt
import pandas as pd
import numpy as np
Expand All @@ -16,13 +18,22 @@
import httpx
import threading
import socket
import base64

from bitmind.protocol import ImageSynapse
from bitmind.image_transforms import base_transforms
from bitmind.protocol import ImageSynapse, prepare_image_synapse
from bitmind.utils.uids import get_random_uids
from bitmind.validator.proxy import ProxyCounter
import bitmind


def preprocess_image(b64_image):
image_bytes = base64.b64decode(b64_image)
image_buffer = BytesIO(image_bytes)
pil_image = Image.open(image_buffer)
return base_transforms(pil_image)


class ValidatorProxy:
def __init__(
self,
Expand Down Expand Up @@ -131,11 +142,14 @@ async def forward(self, request: Request):
bt.logging.warning("[ORGANIC] No recent miner uids found, sampling random uids")
miner_uids = get_random_uids(self.validator, k=self.validator.config.neuron.sample_size)

image = preprocess_image(payload['image'])

bt.logging.info(f"[ORGANIC] Querying {len(miner_uids)} miners...")
predictions = await self.dendrite(
axons=[metagraph.axons[uid] for uid in miner_uids],
synapse=ImageSynapse(image=payload['image'], prediction=-1),
deserialize=True
synapse=prepare_image_synapse(image=image),
deserialize=True,
timeout=9
)

bt.logging.info(f"[ORGANIC] {predictions}")
Expand Down

0 comments on commit 57f4599

Please sign in to comment.