Can I use both CPU and GPU cores simultaeneously?
I am currently working on an economic model using anaconda and Im kinda new to this.
The simulation is kinda slower than macbook m1 chips where it would take thrice the amount of time to complete the simulation
I am wondering if I can use both gpu (rx6600) and cpu (r7 5700x) to have as much cores for computing power.
/r/Python
https://redd.it/1gddbc6
How can I incorporate data science in Django project?
Hello, I’m working on a data science project for academic research. I need to do some data analysis (I mean, data acquisition, pre-processing and data processing), specifically, it is about natural language processing so I also need to train a machine learning model I can get an output I can put in a map (a Google map).
I’ve selected Django as the back-end framework I will use together with Flutter to develop my user interface for a mobile app in which I can deploy my map.
So, my question is how can I handle my data analysis code into the Django project so I am able to map the output of my analysis into my geographic map, that is to say: where do I have to put my data analysis logic in the Django project considering I am planning to save the data I retrieve externally into a database based on my models? and, consequently how can I store the analysis into the database?
Somebody told me about using microservices but, is that really necessary? In which cases are they used? And, can I manage this locally or what approach should I use to manage this data processing? at what point would I
/r/django
https://redd.it/1gd0wms
Trying Django {% url %} tag but not working as expected
https://redd.it/1gdan1n
@pythondaily
D Last Week in Medical AI: Top LLM Research Papers/Models (October 19 - October 26)
Last Week in Medical AI: Top LLM Research Papers\/Models \(October 19 - October 26\)
Medical AI Paper of the Week:
Safety principles for medical summarization using generative AI by Google
This paper discusses the potential and challenges of applying large language models (LLMs) in healthcare, focusing on the promise of generative AI to support various workflows. Medical LLM & Other Models:
Medical LLM & Other Models:
BioMistral-NLU: Medical Vocab Understanding
This paper introduces BioMistral-NLU, a generalizable medical NLU model fine-tuned on the MNLU-Instruct dataset for improved performance on specialized medical tasks. BioMistral-NLU outperforms existing LLMs like ChatGPT and GPT-4 in zero-shot evaluations across six NLU tasks from BLUE and BLURB benchmarks.
Bilingual Multimodal LLM for Biomedical Tasks
This paper introduces MedRegA, a novel region-aware medical Multimodal Large Language Model (MLLM) trained on a large-scale dataset called MedRegInstruct.
Metabolic-Enhanced LLMs for Clinical Analysis
This paper introduces Metabolism Pathway-driven Prompting (MPP) to enhance anomaly detection in clinical time-series data by integrating domain knowledge of metabolic pathways into LLMs.
Dermatology Foundation Model
This paper introduces PanDerm, a multimodal dermatology foundation model trained on over
/r/MachineLearning
https://redd.it/1gd6k6j
Django and iOS/android apps?
Is it possible to create one Django web app and also release iOS and android versions of that app without having to write in the native languages? It would be great to avoid having to learn/write in 3 frameworks but also is great for consistency/maintainability, only having to maintain the code in one place
Of course, a Django web app can be used on mobile, but people always seem to say that users want to actually install an iOS/ android app instead. What is the best option here?
/r/django
https://redd.it/1gd77ho
How do I compare a form in CKEditorField and StringField?
I am using flask and flask-sqlalchemy and flask-wtf-forms.
Imagine I have 2 forms where one form is placed in each flask route.
Lets start with the first route and the first form.
The 1st form has the flask wtf field CKEditorField
. Within the route I type zzz
in the form. Next I save this in the Posts
table as the content
column. Now lets switch to the second route and second form.
In the 2nd route I am using StringField
. Then in a form, I input/type zzz
.
Now I am using a custom validator in the form and I query one_or_None
for the Posts
table. If Posts
returns something I then test if posts_db.content == content_form'
I raise the validationerror('the post is not unique")
. This should work but what if I use something like bold in the ckeditor
form. How would I get the output in the second Stringfield
form? The only solution I can think of is passing on the variable posts_db
in the route. Does anyone have any other suggestions?
TLDR:
I have 2 forms. The 1st form being CKEditorField
,in the 1st route, which I fill with the text 'zzz' then save it the Posts
db
/r/flask
https://redd.it/1gcujm2
D Self-Promotion Thread
Please post your personal projects, startups, product placements, collaboration needs, blogs etc.
Please mention the payment and pricing requirements for products and services.
Please do not post link shorteners, link aggregator websites , or auto-subscribe links.
--
Any abuse of trust will lead to bans.
Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the title.
--
Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.
/r/MachineLearning
https://redd.it/1gd0v8r
Configuration format
I currently use JSONs for storing my configurations and was instead recommended YAML by a colleague. I tried it out, and it looks decent. Big fan of the ability to write comments. I want to switch, but wanted to get opinions regarding pros and cons from the perspective of file size, time taken to read/write and how stable are the corresponding python libraries used to handle them.
My typical production JSONs are ~50 MB. During the research phase, they can be upto ~500 MB before pruning.
/r/Python
https://redd.it/1gcq5rg
🎉 Introducing dj-announcement-api
package 🎉
We're thrilled to announce the release of `dj-announcement-api`, a versatile Django package developed by Lazarus to simplify and optimize the management and distribution of announcements through a robust API.
# Key Features
Full, Optimizable API: Manage announcements programmatically with an API designed for high performance and scalability.
Targeted Announcements: Create detailed, categorized announcements directed at specific user audiences.
Auto-Assign Audiences: Automatically assign users to relevant audiences for seamless, targeted communication.
Scheduling Options: Schedule announcements with customizable publication and expiration dates to deliver information at the right time.
Ideal for modern Django applications with dynamic needs, dj-announcement-api
brings flexibility, scalability, and ease of use for any project needing streamlined announcement management. Check it out on PyPI: dj-announcement-api on PyPI Source Code and Docs on GitHub: dj-announcement-api on GitHub
/r/django
https://redd.it/1gch3py
P Shape-restricted regression with neural networks
Some time ago at work we had to enforce that our model learns an increasing function of a feature. For example, the probability of winning an auction as a function of the bid should increase. Recently, I encountered the paper https://arxiv.org/abs/2209.04476 on regression with shape-restricted functions, and wanted to make it a bit more tangible, with actual code that trains such a model.
So it resulted in a blog post: https://alexshtf.github.io/2024/10/14/Shape-Restricted-Models.html
There's also a notebook with the accompanying code: https://github.com/alexshtf/alexshtf.github.io/blob/master/assets/shape\_constrained\_models.ipynb
I used to work on ads quite a lot .So such models seem useful in this industry - predicting the probability of winning an ad auction given the bid. I hope it's also useful elsewhere.
So I hope you'll enjoy it! It's a big 'mathy', but you know, it can't be otherwise.
/r/MachineLearning
https://redd.it/1gcpl03
Every unicode character can be a variable name in globals and locals
Hello. Reading about walrus operator I've seen φ used as a variable. That defied my knowledge (_, a-z, A-Z, 0-9), and I thought "if φ is valid, why 🍆 isn't?".
After a bit of try, I've come up with this.
initial = 127810
for i in range(10):
variable = chr(initial + i)
locals()variable = f"Value of {variable} is {ord(variable)}"
print(locals().get("🍆"))
Getting
Value of 🍆 is 127814
Therefore, 🍆 can be a variable in Python (in globals and locals). But also horizontal tab, backspace, null character, ... can be. Of course, they are not accessible in the code the same way than φ or hello_world, but still it's a nice gimmick. I hope you find it fun and/or useful.
But now the real thing. In this context, do you know if using backspace or null as a variable in globals could break the program in execution time? Thank you.
/r/Python
https://redd.it/1gc2gmg
datamule: download, parse, and construct structured datasets from SEC filings
Link: https://github.com/john-friedman/datamule-python
# What my project does
1. Download SEC filings quickly. (Bulk downloads are also available, benchmark is \~2 min/year for every 10-K/10-Q since 2001
2. Parse SEC filings quickly. (Currently only 8-K, 13F-HR Information tables are implemented. 10-K/10-Q coming next week)
3. Convert SEC textual filings directly into structured datasets.
4. Watch for new filings.
5. Has a basic tool calling chatbot with artifacts. Doesn't do anything useful yet, but was fun to make.
# Target Audience
Grad students looking to save money on expensive datasets, quants with side projects, software engineers looking to build commercial projects, and WSB people trying fun new trading strategies. In the future I'd like to make the chatbot code a bit cleaner so it can be used as a tutorial project for masters students w/ finance but not programming experience.
# Comparison
Getting SEC data in bulk is surprisingly expensive. Parsed SEC data is even more expensive. Derived datasets such as board of directors data is also expensive (something like 35k/license).
# Contribution
Greatly appreciated. Also SEC feature requests + QoL suggestions are very useful.
Links: https://github.com/john-friedman/datamule-python
/r/Python
https://redd.it/1gc7yac
Migrating to Django 5
https://jmduke.com/posts/post/django-5/
/r/django
https://redd.it/1gcgqga
Project Open source video indexing/labelling/tag generation tool.
Guys, I'm looking for an open source tool or any repo that can help me generate tags for video to categorize multiple videos and do further analysis.
An equivalent of what I want is Azure AI clvideo inxer, but If there was such a open source tool, it will solve the problem.
/r/MachineLearning
https://redd.it/1gccyhp
How do I solve this circular import error between two models ?
Here's a simplified to the maximum version of my code:
from app2.models import Model2
class Model1(models.Model):
model2 = models.OneToOneField(Model2, ondelete=models.CASCADE, null=True)
# In another app
from app1.models import Model1
class Model2(models.Model):
field1 = models.CharField(maxlength=90)
def save(self):
super().save()
objectmodel1 = Model1.objects.filter()
# Process on objectmodel1
In there, there are two models. One in each of two apps. Model1 needs to import Model2 to define a One To One relationship and Model2 needs to import Model1 because it needs to use it in its save method hence the circular import error I get. I could import Model1 in the save method of Model2 directly but I've read it is not recommended for multiple understandable reasons.
I also heard I could put the name of the model "Model2" in
/r/djangolearning
https://redd.it/1gcbct4
Discord recommendations for Flask Devs?
What are the best Discords for Flask developers? Some general python discords are welcomed as well.
/r/flask
https://redd.it/1gdg84b
profile pic not showing
models.py:
class Profile(models.Model):
user = models.OneToOneField(User,ondelete=models.CASCADE)
userimage = models.ImageField(uploadto="userpic/")
def str(self):
return self.user.username
urls.py:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += +static(settings.MEDIAURL, documentroot=settings.MEDIAROOT)
html template:
<img src="{{ user.profile.userimage.url }}" alt="img">
error showing in terminal:
Not Found: /picture/userpic/10987982.jpg
GET /picture/userpic/10987982.jpg HTTP/1.1" 404 2270
the image stored in picture/user_pic/ but not rendered on html template but user name and first name is render in html template
/r/django
https://redd.it/1gdbbd8
We're thinking of rewriting our go / java API in python, what do we need to think about?
Background:
We have a horrible hodgepodge of APIs in front of our data platform, java that mostly calls underlying functions in the go (with slightly more user friendly calls). The go API often calls bash scripts to do the actual work. Most of the stuff the API does is building a call for an external service like doing spark submit on the file the user has provided or creating a table in hive with details the user has provided. The java API has swagger and is mostly what all users call.
One option we have is to rewrite it all in go getting rid of java and bash, write swagger into the go and all the things the java does.
But we're predominantly a python shop, which means whenever something needs to be done with the APIs only a few people are prepared to go near it and it's recieved very little change over the years where the rest of the platform is moving on rapidly.
So a few of us are in favour for rewiteing it all in something like fastAPI, (or maybe black sheep?)
From what I understand this would basically give us swagger for free and mean there
/r/Python
https://redd.it/1gdavp9
Looking for someone willing to join a call with me to review my code
I'm working on Django Rest Framework and built REST API with MySQL workbench as database, I've got most of the code done, but I'm facing bugs in authentication that I've been stuck on for a really long time and I can't move on with my project without fixing them, I really tried everything and I'm trying this as a last option, I don't want anyone to write me code, I'm suggesting if someone is willing to join a discord call with me where I can share my screen and they can review my code and maybe tell me what I've been doing wrong. it's not a large project and I'll make sure I don't take much time, it'll be much appreciated, thanks for everyone in advance :)
/r/django
https://redd.it/1gd7jpy
How did you first learn about Python?
How did all of you stumble upon python? I saw someone writing python in RuneScape one day and became curious. Then I dipped into front end frameworks like html and css, then JavaScript and python
/r/Python
https://redd.it/1gcwcex
Moving to Canada Soon! Looking to Connect with Fellow Django Devs
Hey everyone! I'm moving to Canada in about four months, and I'm excited to connect with people working with Django. I have around three years of experience building large-scale Django apps that handle millions of data entries, and I'm always looking to improve and learn from others.
If you're in Canada or familiar with the Django scene there, I'd love to hear any insights, or tips, or just chat about the latest in Django development! 😊
/r/django
https://redd.it/1gcx9ax
Sunday Daily Thread: What's everyone working on this week?
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/1gcygl6
D Train on full dataset after cross-validation? Semantic segmentation
I am currently working on a semantic segmentation project of oat leaf disease symptoms. The dataset is quite small, 16 images. Due to time constraints, I won't be able to extend this.
I am currently training 3 models, 3 backbones, and 3 losses--using 5-fold cross validation and grid search.
Once this is done, I plan to then run cross validation on a few different levels of augmentations per image.
My question is this:
Once I have established the best model, backbone, loss, and augmentation combination, can I train on the full dataset since it is so small? If I can do this, how do I know when to stop training to prevent overfitting but still adequately learn the data?
I have attached an image of some results so far.
https://preview.redd.it/sx394c58l5xd1.png?width=2000&format=png&auto=webp&s=3cefbf5c84bf3fbf48936c47810c4e3039dcb410
Thanks for any help you can provide!
/r/MachineLearning
https://redd.it/1gct22r
Why my Django Administration page looks like this
https://preview.redd.it/zq6i8sq825xd1.png?width=1920&format=png&auto=webp&s=accd043c3df996c0e52d4a4f380ff86063c72cab
/r/django
https://redd.it/1gcqq5d
Hosting my Flask application - selecting a provider?
I'm currently looking to host my Flask application that is completely finished and just needs to go online, but as it is my first project that is actually going online I'm looking for some guidance with selecting a provider.
The app is a statistics application that I built for a company. It's a fairly basic Flask application with upwards of 8 .py scripts, a .json dataset and and some web templates, images and .css files. Everything is running smoothly and perfectly on the built-in development server, so I'm hoping it will continue to do so once hosted properly.
Security is a concern (if that matters when it comes to selecting the provider) as the application uses developer keys and some other credentials (that I've done all I can to secure within the app itself). I will need to install a log-in system of some sort so if any provider can make that easy that would be a major advantage.
Hoping for some pointers or just to hear some experiences with different providers - and thanks in advance :-)
T
/r/flask
https://redd.it/1gay069
I created a Django rest framework package for MFA/2FA
I'm excited to announce the release of drf-totp, a package that brings Time-Based One-Time Password (TOTP) Multi-Factor Authentication (MFA) to the Django Rest Framework.
What My Project Does
drf-totp provides a simple and secure way to add an extra layer of authentication to your API endpoints, protecting your users' accounts from unauthorized access. With this package, you can easily integrate TOTP MFA into your Django Rest Framework project, supporting popular authenticator apps like Google Authenticator and Authy.
Key Features
1. Easy integration with Django Rest Framework
2. Supports popular authenticator apps like Google Authenticator and Authy
Target Audience
drf-totp is designed for developers and teams building secure API-based applications with Django Rest Framework. This package is suitable for production environments and can be used to add an extra layer of security to existing projects or new applications.
Comparison
While there are other MFA solutions available for Django, drf-totp is specifically designed for the Django Rest Framework and provides a seamless integration experience. Unlike other solutions that may require extensive configuration or customization, drf-totp is easy to set up and use, making it an ideal choice for developers who want to add TOTP MFA to their API endpoints quickly and securely.
Check out the GitHub repo for installation instructions and example
/r/Python
https://redd.it/1gcl0hk
A fun use of itertools in gamedev
For the last 3/4 years I've been working on this game in Python/Pygame
There's a lot of puzzling mechanics and tight movements required which got me to thinking of some hazards I could put in the game.
Anyway, fast forward a bit and I have one particular hazard which you can see here:
https://i.imgur.com/swY30rB.mp4
If that hurts your head, there's a simpler "up/down" version here
https://i.imgur.com/yE7LZGa.gif
While doing these I realised it was just cycling (a very obvious clue) through a list of different vectors. Which brought me to my favourite but often-unused module... itertools
!
### itertools.cycle
to the rescue!
When I saw this pattern I realised I could finally indulge myself and use itertools.cycle
. I love the itertools modules but usually never get to use them in my day-to-day.
For those not in the know, itertools.cycle describes itself as this (paraphrased for brevity)
> Make an iterator returning elements from the iterable. Repeats indefinitely
In the first example we're just cycling through a version of a circle
[1,0, # right
0, 1, # down
-1,0, # left
0, -1
/r/Python
https://redd.it/1gch0qm
Build a 'Chat with Wikipedia' App Using Flask and Gemini API (Demo + Code)
Hey Community,
I’m excited to share how quick and easy it is to bring your apps and ideas to life using Flask—the learning curve is really user-friendly! I recently built a "Chat with Wikipedia" app using Flask, powered by the Gemini API.
You can check out a demo on my YouTube channel (link provided in the video description), where you’ll also find the code.
Here’s a quick overview: this app lets you enter a Wikipedia page title and chat with the page to ask questions about it.
Next on my list is to develop a Chrome extension to extend this concept, making it possible to chat with any website directly.
Let me know what you think!
https://www.youtube.com/watch?v=1mxTvmpDV-I
/r/flask
https://redd.it/1gbrfs2
one year of peer review D
My manuscript has been in peer review for 10 and half months to ieee. The last time I contacted the journal to ask about the situation, they told me that they were looking for reviewers. It's been two months since the last email. I have no response from the journal. The manuscript is still in peer review. My question is, is it normal for it to take so long? Is this a good sign that my paper will be accepted? If it were the opposite, would they not hesitate to reject it directly or is it normal for it to take so long and then reject it in the end? The paper is about natural language peocessing
/r/MachineLearning
https://redd.it/1gbzxbf