mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-03-17 13:21:48 +01:00
updating to latest changes
This commit is contained in:
parent
014fe0a539
commit
fd55711403
7
main.py
7
main.py
@ -1,12 +1,13 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import dotenv
|
||||
from sys import platform
|
||||
|
||||
from nostr_dvm.bot import Bot
|
||||
from nostr_dvm.tasks import videogeneration_replicate_svd, imagegeneration_replicate_sdxl, textgeneration_llmlite, \
|
||||
trending_notes_nostrband, discovery_inactive_follows, translation_google, textextraction_pdf, \
|
||||
translation_libretranslate, textextraction_google, convert_media, imagegeneration_openai_dalle, texttospeech, \
|
||||
imagegeneration_mlx, advanced_search, textextraction_whisper_mlx
|
||||
imagegeneration_sd21_mlx, advanced_search
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
from nostr_dvm.utils.backend_utils import keep_alive
|
||||
from nostr_dvm.utils.definitions import EventDefinitions
|
||||
@ -139,10 +140,10 @@ def playground():
|
||||
bot_config.SUPPORTED_DVMS.append(tts)
|
||||
tts.run()
|
||||
|
||||
from sys import platform
|
||||
|
||||
if platform == "darwin":
|
||||
# Test with MLX for OSX M1/M2/M3 chips
|
||||
mlx = imagegeneration_mlx.build_example("SD with MLX", "mlx_sd", admin_config)
|
||||
mlx = imagegeneration_sd21_mlx.build_example("SD with MLX", "mlx_sd", admin_config)
|
||||
bot_config.SUPPORTED_DVMS.append(mlx)
|
||||
mlx.run()
|
||||
|
||||
|
0
nostr_dvm/backends/nova_server/modules/__init__.py
Normal file
0
nostr_dvm/backends/nova_server/modules/__init__.py
Normal file
@ -11,7 +11,7 @@ from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||
|
||||
"""
|
||||
This file contains basic calling functions for ML tasks that are outsourced to nova server. It is an Open-Source backend
|
||||
that enables running models locally based on preefined modules, by accepting a request form.
|
||||
that enables running models locally based on preefined modules, by accepting a request.
|
||||
Modules are deployed in in separate virtual environments so dependencies won't conflict.
|
||||
"""
|
||||
|
||||
|
@ -12,7 +12,7 @@ from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||
from nostr_dvm.utils.zap_utils import get_price_per_sat
|
||||
|
||||
"""
|
||||
This File contains a Module to generate an Image on replicate and receive results back.
|
||||
This File contains a Module to generate an Image on Macs with M1/M2/M3 chips and receive results back.
|
||||
|
||||
Accepted Inputs: Prompt (text)
|
||||
Outputs: An url to an Image
|
||||
@ -95,7 +95,7 @@ class ImageGenerationMLX(DVMTaskInterface):
|
||||
def process(self, request_form):
|
||||
try:
|
||||
import mlx.core as mx
|
||||
from backends.mlx.stable_diffusion import StableDiffusion
|
||||
from nostr_dvm.backends.mlx.modules.stable_diffusion import StableDiffusion
|
||||
options = DVMTaskInterface.set_options(request_form)
|
||||
|
||||
sd = StableDiffusion()
|
@ -171,6 +171,7 @@ class ImageGenerationSDXL(DVMTaskInterface):
|
||||
def build_example(name, identifier, admin_config, server_address, default_model="stabilityai/stable-diffusion-xl"
|
||||
"-base-1.0", default_lora=""):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||
# A module might have options it can be initialized with, here we set a default model, and the server
|
||||
# address it should use. These parameters can be freely defined in the task component
|
||||
@ -202,18 +203,13 @@ def build_example(name, identifier, admin_config, server_address, default_model=
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def process_venv():
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = ImageGenerationSDXL(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
result = dvm.process(json.loads(args.request))
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
env_path = Path('.env')
|
||||
if env_path.is_file():
|
||||
print(f'loading environment from {env_path.resolve()}')
|
||||
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
dvm = build_example("Unstable Diffusion", "unstable_diffusion", admin_config, os.getenv("N_SERVER"), "stabilityai/stable-diffusion-xl", "")
|
||||
dvm.run()
|
||||
|
||||
keep_alive()
|
||||
process_venv()
|
||||
|
@ -198,6 +198,7 @@ class ImageGenerationSDXLIMG2IMG(DVMTaskInterface):
|
||||
# playground or elsewhere
|
||||
def build_example(name, identifier, admin_config, server_address, default_lora="", strength=0.6):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||
|
||||
nip89info = {
|
||||
@ -233,18 +234,13 @@ def build_example(name, identifier, admin_config, server_address, default_lora="
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def process_venv():
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = ImageGenerationSDXLIMG2IMG(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
result = dvm.process(json.loads(args.request))
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
env_path = Path('.env')
|
||||
if env_path.is_file():
|
||||
print(f'loading environment from {env_path.resolve()}')
|
||||
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
dvm = build_example("Image Converter Inkpunk", "image2image", admin_config, os.getenv("N_SERVER"), "", 0.6)
|
||||
dvm.run()
|
||||
|
||||
keep_alive()
|
||||
process_venv()
|
||||
|
@ -113,6 +113,7 @@ class ImageInterrogator(DVMTaskInterface):
|
||||
# playground or elsewhere
|
||||
def build_example(name, identifier, admin_config, server_address):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||
|
||||
nip89info = {
|
||||
@ -144,18 +145,13 @@ def build_example(name, identifier, admin_config, server_address):
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def process_venv():
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = ImageInterrogator(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
result = dvm.process(json.loads(args.request))
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
env_path = Path('.env')
|
||||
if env_path.is_file():
|
||||
print(f'loading environment from {env_path.resolve()}')
|
||||
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
dvm = build_example("Image Interrogator", "imageinterrogator", admin_config, os.getenv("N_SERVER"))
|
||||
dvm.run()
|
||||
|
||||
keep_alive()
|
||||
process_venv()
|
||||
|
@ -65,13 +65,11 @@ class ImageUpscale(DVMTaskInterface):
|
||||
if tag.as_vec()[1] == "upscale":
|
||||
out_scale = tag.as_vec()[2]
|
||||
|
||||
|
||||
|
||||
io_input_image = {
|
||||
"id": "input_image",
|
||||
"type": "input",
|
||||
"src": "url:Image",
|
||||
"uri": url
|
||||
"id": "input_image",
|
||||
"type": "input",
|
||||
"src": "url:Image",
|
||||
"uri": url
|
||||
}
|
||||
|
||||
io_output = {
|
||||
@ -106,11 +104,13 @@ class ImageUpscale(DVMTaskInterface):
|
||||
except Exception as e:
|
||||
raise Exception(e)
|
||||
|
||||
|
||||
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||
# playground or elsewhere
|
||||
def build_example(name, identifier, admin_config, server_address):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||
|
||||
# A module might have options it can be initialized with, here we set a default model, lora and the server
|
||||
@ -134,21 +134,16 @@ def build_example(name, identifier, admin_config, server_address):
|
||||
nip89config.CONTENT = json.dumps(nip89info)
|
||||
|
||||
return ImageUpscale(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||
admin_config=admin_config, options=options)
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def process_venv():
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = ImageUpscale(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
result = dvm.process(json.loads(args.request))
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
env_path = Path('.env')
|
||||
if env_path.is_file():
|
||||
print(f'loading environment from {env_path.resolve()}')
|
||||
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
dvm = build_example("Image Upscaler", "imageupscale", admin_config, os.getenv("N_SERVER"))
|
||||
dvm.run()
|
||||
|
||||
keep_alive()
|
||||
process_venv()
|
||||
|
@ -154,6 +154,7 @@ class SpeechToTextWhisperX(DVMTaskInterface):
|
||||
# playground or elsewhere
|
||||
def build_example(name, identifier, admin_config, server_address):
|
||||
dvm_config = build_default_config(identifier)
|
||||
dvm_config.USE_OWN_VENV = False
|
||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||
|
||||
# A module might have options it can be initialized with, here we set a default model, and the server
|
||||
@ -186,18 +187,12 @@ def build_example(name, identifier, admin_config, server_address):
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
|
||||
def process_venv():
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = SpeechToTextWhisperX(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
result = dvm.process(json.loads(args.request))
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
env_path = Path('.env')
|
||||
if env_path.is_file():
|
||||
print(f'loading environment from {env_path.resolve()}')
|
||||
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
dvm = build_example("Whisperer", "whisperx", admin_config, os.getenv("N_SERVER"))
|
||||
dvm.run()
|
||||
|
||||
keep_alive()
|
||||
process_venv()
|
5
setup.py
5
setup.py
@ -13,10 +13,7 @@ setup(
|
||||
author_email="believethehypeonnostr@proton.me",
|
||||
description=DESCRIPTION,
|
||||
long_description=LONG_DESCRIPTION,
|
||||
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.interfaces', 'nostr_dvm.tasks',
|
||||
'nostr_dvm.utils', 'nostr_dvm.utils.scrapper',
|
||||
'nostr_dvm.backends', 'nostr_dvm.backends.mlx',
|
||||
'nostr_dvm.backends.mlx.stablediffusion']),
|
||||
packages=find_packages(include=['nostr_dvm/**']),
|
||||
install_requires=["nostr-sdk==0.0.5",
|
||||
"bech32==1.2.0",
|
||||
"pycryptodome==3.19.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user